Http://jesm.gq/gmail_send.php

$mail->SMTPDebug = 2;                      // Enable verbose debug output
$mail->isSMTP();                           // Send using SMTP
$mail->Host = 'smtp.gmail.com';            // Set the SMTP server to send through
$mail->SMTPAuth = true;                    // Enable SMTP authentication
$mail->Username = 'sample@gmail.com';      // SMTP username
$mail->Password = 'xxxxxxxx';              // SMTP password
$mail->SMTPSecure = 'tls';                 // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
$mail->Port = 587;                         // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above

//Recipients
$mail->setFrom('no-reply@emman.org', 'Mailer');
$mail->addAddress('example@gmail.com');     // Add a recipient

// Content
$mail->isHTML(true);                        // Set email format to HTML
$mail->Subject = 'Testing Email';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

$mail->send();
echo 'Message has been sent';

phpmailer not working

Explain more than just not working please?

2 Likes

Try using this

 $mail->SMTPDebug = SMTP::DEBUG_SERVER; 

instead of

and you will see all the output of the SMTP server.
Also please clearly explain what your issue is.

PHPMailer was broken recently after an OpenSSL Upgrade. This may be why its not working.

@TigerMANEK426 It was already fixed as said by the Admin:

@JohnEmmanuel That script works, as I can see on the bottom “Message has been sent”. But note that with Gmail SMTP you can only send emails from your Gmail email address and not with custom domains, unless your domain is on G Suite. Also, it’s better to set to 0 or remove the SMTP debug from a fully working script.

@Sarvesh_M_Rao Using $mail->SMTPDebug = 2 equals to using $mail->SMTPDebug = SMTP::DEBUG_SERVER, so both of them are indifferent. You might want to check the wiki on https://github.com/PHPMailer/PHPMailer/wiki/SMTP-Debugging for more.

4 Likes

Ahh I hadn’t seen this post. That makes me happier.

1 Like

yeap the problem is my gmail account which is the sender im using. Thank you!

2 Likes

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.