Re: Gmail/email & PHP
| From: | Richard | Date: | Sat, 31 May 2025 00:23:07 +0000 |
| Subject: | Re: Gmail/email & PHP | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-328718@lists.php.net to get a copy of this message | ||
is the password you are using:
$mail->Password = 'PASSWRD';
your google/gmail (webmail) login pw or an app password?
[please do not include my address in replies. i'm (obviously) on the
list and will see your responses that way.]
> Date: Saturday, May 31, 2025 11:56:13 +1200
> From: gordonisnz@gmail.com
>
> heres my test script :-
>
> all i want to do is send (& receive - using a different address)
> emails via PHP
>
> The latest error i'm getting is:- Mailer Error: SMTP Error: Could
> not authenticate.
>
> <?php
>
> use PHPMailer\PHPMailer\PHPMailer;
> use PHPMailer\PHPMailer\Exception;
>
>
> require
> '/home/users/web/b2978/pow.kwisternet/usr/phpmailer/PHPMailer-maste
> r/src/Exception.php'; require
> '/home/users/web/b2978/pow.kwisternet/usr/phpmailer/PHPMailer-maste
> r/src/PHPMailer.php'; require
> '/home/users/web/b2978/pow.kwisternet/usr/phpmailer/PHPMailer-maste
> r/src/SMTP.php';
>
> $mail = new PHPMailer(true);
> try {
> $mail->isSMTP();
> $mail->Host = 'smtp.kwister.com';
> $mail->SMTPAuth = true;
> $mail->Username = 'email1@kwister.com';
> $mail->Password = 'PASSWRD';
> $mail->SMTPSecure = 'tls';
> $mail->Port = 587;
> $mail->SMTPOptions = [
> 'ssl' => [
> 'verify_peer' => false,
> 'verify_peer_name' => false,
> 'allow_self_signed' => true,
> ],
> ];
>
>
> $mail->setFrom('email1@kwister.com', 'Kwister Mailer');
> $mail->addAddress('email2@kwister.com');
> $mail->Subject = 'PHPMailer Test mailer';
> $mail->Body = 'This is a PHPMailer test email.';
>
> $mail->send();
> echo 'Message sent';
> } catch (Exception $e) {
> echo "Mailer Error: {$mail->ErrorInfo}";
> }
>
>
> ?>
>
>
>
> On Sat, 31 May 2025 at 11:22, Richard
> <inbound-lists-php@listmail.innovate.net> wrote:
>>
>> In order for people to provide much assistance you need to give
>> details of what you are trying to do and how you are doing it as
>> well the results you are getting - including errors and potentially
>> information from your mail logs.
>>
>> If you are trying to deliver mail to gmail on port 25 you'll need
>> to have the necessary DMARC set up for the FQDN that you're using.
>> For the submission ports - 465/587 - and to retrieve mail you'll
>> either need to support Oauth 2.0 or be using an app password -
>> rather than an account login id/pw for authentication.
>>
>> These are just a couple of issues. There are a range of other
>> things that can be obstacles, but without knowing details it's not
>> worth trying to do more guessing.
>>
------------ End Original Message ------------