Phpmailer: Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

Created on 23 Mar 2016  路  5Comments  路  Source: PHPMailer/PHPMailer

Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

All 5 comments

You want me to tell you how to click a link?

My code is:

require_once 'Phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer;

$mail->SMTPDebug = 3;
$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'smtp.mailgun.org';                     // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = '[email protected]';   // SMTP username
$mail->Password = 'password';                           // SMTP password
$mail->SMTPSecure = 'tls';                            // Enable encryption, only 'tls' is accepted


$mail->From = '[email protected]';
$mail->FromName = 'Email';
$mail->addAddress('[email protected]');                 // Add a recipient

$mail->WordWrap = 50;                                 // Set word wrap to 50 characters

$mail->Subject = 'text';
$mail->Body    = 'text body';

if(!$mail->send()) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    echo 'Message has been sent';
}

Why have you based your code on an obsolete example instead of the ones on here? Did you actually read the guide? What does your debug output say?

Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
how to solve plz ans

@Ssasikuma Follow the link, and read what it says above - I'm not about to give you a different answer.

Was this page helpful?
0 / 5 - 0 ratings