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
Fatal Error: Uncaught Argumentcounterror: Too Few Arguments to Function
How to Make First Letter of a Word Capital
Create Unique Poll/Vote/Survey in PHP
Add Prefix to Auto-Increment in MySQL Db
What Is the Best PHP Dom 2 Array Function
MySQL Stored Function to Create a Slug
Using PHP Code in Smarty Tpl File
PHP Session Id Changing on Every Request
Insert Value List Does Not Match Column List: 1136 Column Count Doesn't Match Value Count
Is $_Server['Http_Referer'] Safe
How to Disable Adding Properties into a Class from an Instance of the Class
Timestamps of Start and End of Month
Pass the Chosen Product Variations Data into Contact Form 7 Enquiry Form
How to Iterate by Row Through a MySQL Query in PHP
How to Add a PHP Simplexmlelement to Another Simplexmlelement