Phpmailer Send Gmail Smtp Timeout

phpmailer send gmail smtp timeout

Here is a working example:

  require_once ( 'class.phpmailer.php' ); // Add the path as appropriate
$Mail = new PHPMailer();
$Mail->IsSMTP(); // Use SMTP
$Mail->Host = "smtp.gmail.com"; // Sets SMTP server
$Mail->SMTPDebug = 2; // 2 to enable SMTP debug information
$Mail->SMTPAuth = TRUE; // enable SMTP authentication
$Mail->SMTPSecure = "tls"; //Secure conection
$Mail->Port = 587; // set the SMTP port
$Mail->Username = 'MyGmail@gmail.com'; // SMTP account username
$Mail->Password = 'MyGmailPassword'; // SMTP account password
$Mail->Priority = 1; // Highest priority - Email priority (1 = High, 3 = Normal, 5 = low)
$Mail->CharSet = 'UTF-8';
$Mail->Encoding = '8bit';
$Mail->Subject = 'Test Email Using Gmail';
$Mail->ContentType = 'text/html; charset=utf-8\r\n';
$Mail->From = 'MyGmail@gmail.com';
$Mail->FromName = 'GMail Test';
$Mail->WordWrap = 900; // RFC 2822 Compliant for Max 998 characters per line

$Mail->AddAddress( $ToEmail ); // To:
$Mail->isHTML( TRUE );
$Mail->Body = $MessageHTML;
$Mail->AltBody = $MessageTEXT;
$Mail->Send();
$Mail->SmtpClose();

if ( $Mail->IsError() ) {
echo "ERROR<br /><br />";
}
else {
echo "OK<br /><br />";
}

Timeout error when sending outgoing mail via SMTP & PHPMailer

The problem was that I had no MTA installed on my Digital Ocean droplet.

I followed these instructions:

https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-postfix-as-a-send-only-smtp-server-on-ubuntu-14-04

and set up postfix as a send-only smtp server.

Next, I set up a Google Apps SMTP Relay to allow emails to come from my Google Apps address.

This way, sent emails are saved on my gmail's sent folder and emails are much less likely to be marked as spam.

Google SMTP connection timed out

So if anyone is interested in solution, i just contacted to my support and asked if they have any limitations. They said that they doesn't have any, and they also resetted my SMTP, so it started to work fine.

SMTP Connection Timeout PHP Email

Well it might a case where the ISP is Blocking the SMTP. And I know I am not giving a direct solution. It won't hurt to try other services to send your mail out thru API, thereby eliminating SMTP altogether.

I have good experiences with Mailgun and Mandrill . They both have extension documentation and PHP SDK for API and can also be used thru SMTP.
Best Wishes.

SMTP error while using PHPMailer for gmail even after connecting to gmail SMTP

You should base your code on the provided gmail example. You're trying to use SMTPSecure = 'ssl' with Port = 587. That won't work: use tls with port 587. You're also making a mess of including the files. Maybe you should try reading the docs? Even the example in the readme does this correctly.



Related Topics



Leave a reply



Submit