Re: [PHP] Gmail/email & PHP

Date: Saturday, May 31, 2025 09:58:18 +1200
From: gordonisnz@gmail.com

Hello. is there another good PHP forum ? (this seems all about php
development)

I'm wondering if anyone is using PHP to send/receive emails using
google/Gmail servers ?
I'm using AI to help, and still going round-round in circles..

Are there any 2025 / recent instructions that deal with any recent
changes that Google has implemented...

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.

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 ------------

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-master/src/Exception.php';
require '/home/users/web/b2978/pow.kwisternet/usr/phpmailer/PHPMailer-master/src/PHPMailer.php';
require '/home/users/web/b2978/pow.kwisternet/usr/phpmailer/PHPMailer-master/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.

--

Gordon.

On Sat, 31 May 2025 at 12:24, Richard
<inbound-lists-php@listmail.innovate.net> wrote:

is the password you are using:

   $mail->Password = 'PASSWRD';

thats my gmail password (gmail is on a domain)

Gordon.