Send email using Phpmailer with Yahoo/Gmail

I believe, Phpmailer class is most popular class throughout the web. You can easily integrate this class to your application to send email. If you want to send email using gmail smtp or yahoo business email smtp( yahoo free email doesn’t provide smtp, pop services) through this class, you may face some problems like me 😉

I’ve used this class to send email using yahoo business account and gmail account. To send email through yahoo smtp, First get the class files from, remember – you have to take correct version of php4 or php5. Then here is the sample code for your mail sending script with yahoo business smtp –

 require ("class.phpmailer.php");
 $mail = new PHPMailer();
 $mail->From     = "FROM EMAIL ADDRESS";
 $mail->FromName = "FROM NAME";
 $mail->SMTPAuth = true;     // turn of SMTP authentication
 $mail->Username = "YAHOO BUSINESS ACCOUNT";  // SMTP username
 $mail->Password = "YAHOO BUSINESS ACCOUNT PASSWORD"; // SMTP password
 $mail->SMTPSecure = "ssl";
 $mail->Host = "";
 $mail->Port = 465;
 $mail->SMTPDebug  = 2; // Enables SMTP debug information (for testing, remove this line on production mode)
 // 1 = errors and messages
 // 2 = messages only
 $mail->Sender   =  "EMAIL ADDRESS TO RECIEVE BOUNCES";// $bounce_email;
 $mail->ConfirmReadingTo  = "EMAIL ADDRESS TO GET READING REPORT";
 $mail->AddReplyTo("ADDRESS TO GET REPLY","NAME");
 $mail->IsHTML(true); //turn on to send html email
 $mail->Subject = "EMAIL SUBJECT";

 $mail->Body     =  "EMAIL MESSAGE";

That’s it. If you see the following errors on debug

SMTP -> ERROR: Failed to connect to server: Connection timed out (110) Sending failed ()!
SMTP -> ERROR: Failed to connect to server: Connection timed out (110) Failed to send notification to Admin.

you have to confirmed that port 465 is opened, contact your hosting to open this port.

Pretty simple. I believe similar settings will ok with Gmail.

10 thoughts on “Send email using Phpmailer with Yahoo/Gmail

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.