Saturday, June 10, 2006

[GMAIL] - [PHP] - Send email using PHP with Gmail


[ This explains how to use gmail to send emails in php using PHPMailer]

1 Download PHPMailer from http://phpmailer.sourceforge.net
2 Extract to folder phpmailer
3 Create a file email.php
4 Paste this code and change the values in blue as you need (I modified the sample code given on the PHPMailer homepage)

IsSMTP(); // send via SMTP
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "username@gmail.com"; // SMTP username
$mail->Password = "password"; // SMTP password
$webmaster_email = "username@doamin.com"; //Reply to this email ID
$email="username@domain.com"; // Recipients email ID
$name="name"; // Recipient's name
$mail->From = $webmaster_email;
$mail->FromName = "Webmaster";
$mail->AddAddress($email,$name);
$mail->AddReplyTo($webmaster_email,"Webmaster");
$mail->WordWrap = 50; // set word wrap
$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment
$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // attachment
$mail->IsHTML(true); // send as HTML
$mail->Subject = "This is the subject";
$mail->Body = "Hi,
This is the HTML BODY "
; //HTML Body
$mail->AltBody = "This is the body when user views in plain text format"; //Text Body
if(!$mail->Send())
{
  echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
  echo "Message has been sent";
}
?>

5 Open the file class.smtp.php in phpmailer directory
6 Paste this code
$host = "ssl://smtp.gmail.com";
$port = 465;
before the line 104 #connect to the smtp server
Hint: Search for #connect
7 Open this page in browser and it will send the email using GMail.

Hint: When you want to email the details from a form, set the variables using the form variables.
eg. $mail->Username=$_POST['email']

Share it with others on:

72 Comments:

Blogger thewebcammaster said...

This is the best way to use Gmail Relay SMTP service:
http://www.xpertmailer.com/forum/viewtopic.php?t=48

June 29, 2006 3:22 PM  
Anonymous nagendraprasad said...

hello
I have tried to work out the procedure mentioned but i get a timeout.....can u please help?

July 08, 2006 11:59 AM  
Blogger Deepak Radhakrishnan said...

Check your internet
Check whether you have your firewall setting
If you are in a LAN with firewall blocking the port then you will get this error

July 08, 2006 1:01 PM  
Anonymous nagendraprasad said...

yes i have a firewall....how do i give access privileges to this port....i use mcafee wirewall what are the settings i need to do....plese help....

July 08, 2006 3:21 PM  
Blogger Sprocketonline said...

Gmail requires you to use SSL authentication, a further step is required if you don't already have php configured for this:

1. open your php.ini file, and find the windows extensions part. Now uncomment the extension=php_openssl.dll.

2. Save the php.ini file and restart your server.

3.Try running your php again, it should send the mail.

Note: My script successfully sent the email (I recieved it in my test inbox) but the php script returned a warning:
"Warning: fgets() [function.fgets]: SSL: fatal protocol error in PathToPhpIncludes\class.smtp.php on line 1027"

July 27, 2006 7:45 PM  
Anonymous Anonymous said...

First, let me say that this is the best fix I've seen for sending SMTP autheticated email through GMAIL...and I've tried a bunch of things. It works well...but there's still one problem...I got the same error as the post above:

Warning: fgets() [function.fgets]: SSL: fatal protocol error in C:\wamp\www\phpmailer\class.smtp.php on line 1027


Does anyone know why this might be happening, and how I can get rid of it?

September 29, 2006 1:10 PM  
Anonymous Anonymous said...

Hi,

DOes anyone read this blog? If so, can someone please help answer the question in the last comment?

Thanks,
E

October 08, 2006 5:29 AM  
Anonymous Anonymous said...

On a forum post I found a suggestion:

3. change to fgets() to @fgets() to surpass the ssl error

October 28, 2006 9:06 PM  
Anonymous Anonymous said...

Hey...thanx. @fgets() works

October 28, 2006 10:16 PM  
Blogger figo2476 said...

Hi there

I set up a server at my desktop, then get this error.... No clue...

Warning: fsockopen() [function.fsockopen]: SSL operation failed with code 1. OpenSSL Error messages: error:140770FC:SSL routines:func(119):reason(252) in F:\livingProgrammes\wamp5\www\test_phpmailer\class.smtp.php on line 110

August 03, 2007 1:40 PM  
Blogger Deepak Radhakrishnan said...

Hi Figo2476,

1. uncomment the extension=php_openssl.dll in php.ini
2. Check the port used for SSL

August 03, 2007 8:31 PM  
Blogger CCWHC said...

Wouldn't you need to use 587 and TLS, not 465 and ssl?

August 08, 2007 1:46 AM  
Anonymous <a href="http://www.xanga.com/buy_levitra">Buy Levitra</a> said...

Great article! Thanks.

August 18, 2007 12:33 PM  
Anonymous <a href="http://web.archive.org/web/20070818071347/freewebtown.com/loans1/payday-loans.html">Payday loans</a> said...

Nice Blog!

August 18, 2007 6:29 PM  
Anonymous Anonymous said...

Awesome. It really works. First working solution i've seen...

Btw, for those who didn't realize: in his sample code, he left out the fact that you need to include PHPMailer, and these 2 lines:

$mail=new PHPMailer();
$mail->IsSMTP(); // send via SMTP

August 30, 2007 7:35 AM  
Anonymous Anonymous said...

Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?) in c:\wamp\www\mail1\class.smtp.php on line 106
Mailer Error: Language string failed to load: connect_host




hey this is the error that it shows when i try to run this script....can any body help in this matter....

September 02, 2007 2:16 AM  
Anonymous Anonymous said...

IT's work perfect, thanks!!!!!!!!!!!!!!!!!!!!

September 04, 2007 10:26 AM  
Anonymous <a href="http://courses.cvcc.vccs.edu/ENG112_GROSS/_Chat_Room/000008fd.htm">Anonimous</a> said...

Excellent website. Good work. Very useful. I will bookmark!

September 10, 2007 8:00 AM  
Anonymous Anonymous said...

Bless you. I've spent days trying to get the phpmailer built into Wordpress 2.2 to play nice. When I saw how simple the solution was, I nearly cried. Thanks.

September 25, 2007 7:10 AM  
Anonymous Anonymous said...

I use NuSphere PHP ED, I had to do the following changes to make it work:
In file: email.php my top 4 lines are:
include("class.phpmailer.php");
include("class.smtp.php");
$mail=new PHPMailer();
$mail->IsSMTP();

Uncomment the following in PHP.ini
extension=php_openssl.dll

September 26, 2007 10:05 PM  
Anonymous Kishor said...

Hi all,
Can anyone tell me how to telnet to gmail smtp server (from windows)?

October 09, 2007 5:23 PM  
Anonymous Anonymous said...

Fatal error: Call to undefined function IsSMTP() in /home/www/liveonrent/htdocs/smtp/phpmailer/test2.php on line 7

October 29, 2007 10:29 PM  
Anonymous Anonymous said...

Replace the first line of the above code :-
IsSMTP(); // send via SMTP

with this :-

include("class.phpmailer.php");

$mail=new PHPMailer();
$mail->IsSMTP(); // send via SMTP

It works fine now !
Thanks for the example.

October 29, 2007 10:33 PM  
Blogger Kranti said...

I followed the instructions of editing php.ini file and creating a new email.php file.. but getting the following error
----------------------

Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?) in E:\wamp\www\phpmailer\class.smtp.php on line 106
Mailer Error: SMTP Error: Could not connect to SMTP host.

November 01, 2007 5:50 PM  
Blogger Josh Fraser said...

I just set up Google Apps for my domain and wrote a blog post on my experience. You can learn more about maximizing email deliverability using SPF records and Sender ID.

Tutorial: Sending email through Gmail

November 09, 2007 6:07 AM  
Anonymous Anonymous said...

SMTP with authentication (using GMAIL and PHPMAILER):

Note: I used the classes from http://www.buayacorp.com/files/php/gmail-phpmailer.zip

But I had changed all the code from test.php to the one above.

1) I've got the classes class.phpmailer, class.smtp.php and test.php at the same directory


---------------TEST.php--------
require('class.phpmailer.php');

$mail=new PHPMailer();
$mail->IsSMTP(); // send via SMTP

$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "username@gmail.com"; // SMTP username
$mail->Password = "password"; // SMTP password
$webmaster_email = "username@doamin.com"; //Reply to this email ID
$email="username@domain.com"; // Recipients email ID
$name="name"; // Recipient's name
$mail->From = $webmaster_email;
$mail->FromName = "Webmaster";
$mail->AddAddress($email,$name);
$mail->AddReplyTo($webmaster_email,"Webmaster");
$mail->WordWrap = 50; // set word wrap
//$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment
//$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // attachment
$mail->IsHTML(true); // send as HTML
$mail->Subject = "This is the subject";
$mail->Body = "Hi,
This is the HTML BODY "; //HTML Body
$mail->AltBody = "This is the body when user views in plain text format"; //Text Body
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent";
}
?>
-----------------------

At class.smtp.php

before line 104 (before #connect), use this lines:

$host = "ssl://smtp.gmail.com"; $port = 465;

-----------------------
In the PHP.ini, you need to have this option:

extension=php_openssl.dll

Then, restart your server (wamp/apache/other).

----------------
Change your test.php with your own information... and VOILÁ... it works! It worked for me, and I ad tried a million stuffs before.. lol

PS: Sorry the crappy english. For any help, contact: sol_lunar at iol.pt

Thanks,
Mivla.

November 17, 2007 5:21 PM  
Blogger uswbmail said...

KRANTI:

E:\wamp\www\phpmailer\class.smtp.php on line

-----------

solution:
If you are using localhost, whereas, "wamp", please upload the files
to the live server in order to work
properly... unless,,, you have
configured your local server
to have a smtp connection...

November 22, 2007 12:28 AM  
Blogger lahiru said...

Warning: fsockopen(): no SSL support in this build in C:\apache2triad\htdocs\mailtest\class.smtp.php on line 123 Warning: fsockopen(): unable to connect to smtp.gmail.com:465 in C:\apache2triad\htdocs\mailtest\class.smtp.php on line 123 Mailer Error: SMTP Error: Could not connect to SMTP host

***in server ssl configurations done successfully. So please help me.

December 05, 2007 10:27 AM  
Anonymous Anonymous said...

Omg, thewebcammaster, people like you and the developers of the class should all get handjobs from the open source community. I've been searching 3 hours for a way to get email through php done correctly. Now because of this article and xpertmailer, I will be able to take one step closer to world domination.

December 22, 2007 7:55 AM  
Anonymous Anonymous said...

Hey, i've got error on this
============================
Warning: fsockopen() [function.fsockopen]: php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\dlpd\trial\mail\PHPMailer\class.smtp.php on line 125
============================
why is this??

January 25, 2008 8:11 AM  
Anonymous Bhagyesh said...

Thanks, probably the simplest fix I have seen.
-Bhagyesh

March 10, 2008 10:52 PM  
Anonymous Anonymous said...

Mailer Error: SMTP Error: Could not connect to SMTP host.
Please help me....i don't what to do.

April 05, 2008 7:42 PM  
Anonymous Tim said...

To all the people with the same SSL authentication error. Of course you probably won't see this because you obviously do not read comments before you post them. There is already a solution people. If you do a little reading and pay attention you will figure stuff out.

April 15, 2008 5:40 PM  
Anonymous Anonymous said...

Thanks! Your instructions are spot on. I've been trying to configure gmail for a long time.

April 19, 2008 9:47 PM  
Anonymous Anonymous said...

i can`t use gmail, then i try with other server, and work!!!
The problem is ssl authentication.
Try to use a server without ssl, another that use port 25.

regards!!!

April 20, 2008 7:00 AM  
Anonymous Simon said...

Worked a charm thanks mate. I also had to uncomment the following line from my php.ini

extension=php_openssl.dll

but I think that's because I'm on windows

April 23, 2008 6:40 AM  
Anonymous Anonymous said...

Hi guys, Why I get that error?


Mailer Error: Language string failed to load: connect_host


I don't have my own server...
I pay 20 euro por year for a Windows server... ( Aruba ).
For that reason I can't change the file: php.ini

Anyway i think there something wrong... Maybe because my gmail in in italian? Or maybe because the operating system of the server of Aruba is in italian?

I really don't know...

Please help...

Thanks again to everybody...
Samu

May 13, 2008 3:11 AM  
Anonymous Anonymous said...

can you do this with uploading it to your web server?

May 28, 2008 12:00 PM  
Anonymous Jonathon Baker said...

I put that code in class.smtp.php before #connect to the smtp server, (which was not at line 104 in dreamweaver) and uploaded it and when I ran the program, I got
Parse error: parse error, unexpected T_VARIABLE in /home/www/jonathonbaker.com/class.smtp.php on line 122

May 29, 2008 11:36 AM  
Anonymous anjo said...

PhpMailer Settings to Send email using PHP with Gmail

June 26, 2008 11:40 PM  
Anonymous Anonymous said...

Good. it worked perfectly

July 02, 2008 5:59 AM  
Anonymous Anonymous said...

thank u soooooooo much for the tip..i've been stuck on this problem for a whole week n finally came across this site n figured it out....the only thing i'm concerned with is, is it possible to send to multiple recipients with php mailer?
thanks again!

July 08, 2008 7:35 PM  
Anonymous Anonymous said...

Could not connect to SMTP host. ?>
didnt work what need to do?

July 30, 2008 2:20 AM  
Anonymous Anonymous said...

Finally! Had problems for days until i tried this. Thx!

One problem thou. The mail recipient treats the mail as spam and puts it in the spambox...

August 09, 2008 8:31 PM  
Anonymous Anonymous said...

this also works for yahoo.. thanks

August 10, 2008 6:26 AM  
Anonymous PHP Programmer said...

Hi,

Thank you for the script !
I was searching for a such script for many weeks !

Thank you again !

August 14, 2008 11:43 PM  
Anonymous Max.on.PHP said...

i am getting the error same as Kranti...

is any configuration required in httpd.conf or /extra/httpd-ssl.conf ??

Tanks in advance...

September 25, 2008 12:27 PM  
Blogger thales said...

I found this class pathetic...

September 25, 2008 11:46 PM  
Blogger G R V said...

hi,i can't find the #connect statement in class.smtp.php file,can you please help me where am i going wrong..

thanks :)

September 29, 2008 5:24 PM  
Anonymous Yash said...

OOh yes...it went just OK!!
I didn't notice when was the 1'st post written, but now , we are in 7-11-2008 ,and I found it very very useful
Thank you every body
I wish you all the best!
Salam

November 07, 2008 10:55 PM  
Anonymous Anonymous said...

hi ,
i got this exception while sending mail

fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (php_network_getaddresses: getaddrinfo failed: No such host is known. ) in D:\wamp\www\drupal\class.smtp.php on line 122.


include("class.phpmailer.php");
include("class.smtp.php");
$mail=new PHPMailer();
$mail->IsSMTP(); // send via SMTP

$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "xxx@gmail.com"; // SMTP username
$mail->Password = "xxx"; // SMTP password
$webmaster_email = "xxx@gmail.com"; //Reply to this email ID
$email="xxx@xxx.com"; // Recipients email ID
$name="xxx"; // Recipient's name
$mail->From = $webmaster_email;
$mail->FromName = "Webmaster";
$mail->AddAddress($email,$name);

$mail->Subject = "This is the subject";
$mail->Body = "Hi,
This is the HTML BODY "; //HTML Body"
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent";
}

November 19, 2008 4:33 PM  
Anonymous Anonymous said...

hi i'm using this code but i got an exception

unable to connect to ssl://smtp.gmail.com:465 (php_network_getaddresses: getaddrinfo failed: No such host is known. ) in D:\wamp\www\drupal\class.smtp.php on line 122.


include("class.phpmailer.php");
include("class.smtp.php");
$mail=new PHPMailer();
$mail->IsSMTP(); // send via SMTP

$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "webmaster@xxx.com"; // SMTP username
$mail->Password = "xxxx"; // SMTP password
$webmaster_email = "webmaster@xxx.com"; //Reply to this email ID
$email="xxx@xxx.com"; // Recipients email ID
$name="xxx"; // Recipient's name
$mail->From = $webmaster_email;
$mail->FromName = "Webmaster";
$mail->AddAddress($email,$name);
$mail->AddReplyTo($webmaster_email,"Webmaster");
$mail->WordWrap = 50; // set word wrap
$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment
$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // attachment
$mail->IsHTML(true); // send as HTML
$mail->Subject = "This is the subject";
$mail->Body = "Hi,
This is the HTML BODY "; //HTML Body
$mail->AltBody = "This is the body when user views in plain text format"; //Text Body
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent";
}


?>

November 19, 2008 4:37 PM  
Blogger Tawonga Donnell said...

mine works but returns an 500 internal server error if it is successfull. help!

November 21, 2008 4:45 AM  
Anonymous Stone said...

you are so beatuful for meeeeeeeee
lol
you are great thank you

November 22, 2008 7:26 AM  
Anonymous David said...

For those who use Windows environments, this also seems to work:

http://digiex.net/guides-tutorials/544-configuring-php-under-windows-use-gmail-external-smtp-server-ssl.html

December 01, 2008 6:11 PM  
Anonymous Payday Loans said...

Payday loans come in handy when you are in need of a short term loan!

December 05, 2008 8:16 AM  
Blogger Chathura Jeewantha Ranasingha said...

I must thank you....

Its really working but

Replace first line with

include("class.phpmailer.php");

$mail=new PHPMailer();
$mail->IsSMTP(); // send via SMTP

Chathura Sri Lanka

December 10, 2008 12:06 AM  
Anonymous Johnny said...

Wow! thanks.

I also got fsockopen error.

I was behind a proxy and the error went away when I directly connected my PC to the Internet.

Great script, thanks again :)

December 12, 2008 4:16 PM  
Anonymous buzzby said...

i am gettin gthe same comment. its fine when submitting to the database, it just wont send the email across.

December 15, 2008 6:00 PM  
Anonymous buzzby said...

i am not using gmail at all. so i dont think that uncommenting line relates to me. i am using an IIS tho that requires a username and password. i am still gettin gthat same error of not being able to connect to the smtp host. i am sure i am inputting the right smtp address tho. am using port 25 as well

December 15, 2008 6:03 PM  
Blogger ilViandante said...

Hi!!
This is perfect!!
But don't have to modify the file class.smtp.php:
u can use this:
$mail->Host = "ssl://smtp.gmail.com";
$mail->Port = 465;
$mail->Mailer = "smtp";

Bye

December 17, 2008 4:33 PM  
Anonymous Anonymous said...

This also good one
http://heidisoft.com/blog/gmail-php-send-email-using-php-gmail

December 20, 2008 4:09 PM  
Blogger Achint Verma said...

@kranti
I'm facing similar problem.with same errors. fsockopen error can be removed by enabling php_sockets and php_openssl

I'm not able to figure out the second error. "Mailer Error: SMTP Error: Could not connect to SMTP host." .

please help me out with this i've tried this on many servers.

January 03, 2009 12:20 PM  
Anonymous kimanh said...

Thank you, it works very fine.

It costed me a lot of time searching before I found your blog. Again, thank you very much ^.^

January 06, 2009 2:57 PM  
Blogger dhd said...

Today is the gold für wow second day of 2009 ,world of warcraft gold it also a mesos special for me .cheap wow gold Because i have cheap maplestory mesos a chance to go to an english speech of LiYang and crazy to learn english follow him . He is a firendly,kindly person who make me feel good.wow gold kaufen What‘s more ,maple story mesos he very confidence .And he make me sure what he can do i also can do,as long as i make a determination and force myself to do it every second,Crazy just like him .wow geld I learn one setence from his book ever :maple story items If you want to succeed always force yourself to do more .I can't agree more with him .wow gold farmen To be honest ,when i was a littel girl i already fall in love with english.But what a pity i am poor in english ,Maple Story Account and it make me feel frustrating .So i want to give up many times ,but i can't as i still love it .So i tell mysefl :if you think you can you can wow leveling,and all your maple story power leveling hard work will pay off.wow power leveling Today i am very happy i can listien this wonderful speech of LiYang. I reap a great benifits from him .maple story money As he say :i am the best ,and every one can do it . world of warcraft power leveling Yes,i belive i can do it if i crazy as he

January 22, 2009 10:39 AM  
Blogger Ganga said...

I used this code, it is working fine.
Thanks a lot for sharing this information.

January 30, 2009 5:03 PM  
Blogger MW said...

This is good explanation but it does assume your default SMTP server is/will be gmail and that these values are the defaults PHP will pick up from your phpmailer config ie ssl://smtp.gamil.com:465


The phpmailer class supports properties for setting Host, but any attempt to set the 'Host' property in your script to the necessary values will fail
ie
$mail->Host = "ssl://smtp.gmail.com:465";

will fail by default. This is really because the class wasn't written with GMail in mind.

The phpmailer class parses the host string looking for instances of the character ':' so as to separate SMTP server addresses from related ports. The gotcha with the google SMTP server is that the fully qualified notation 'ssl://smtp.google.com:465' causes the phpmailer SMTP connection parsing algorithm to fail - ie there are two instances of ':' in 'ssl://smtp.google.com:465', phpmailer expects only the second one.

My fix was to edit my copy of class.phpmailer.php, and change part of the code in the SmtpConnect function where the problem is.

from

if(strstr($hosts[$index], ":"))
list($host, $port) = explode(":", $hosts[$index]);
else{
$host = $hosts[$index];
$port = $this->Port;
}

to

if(strstr($hosts[$index], "::"))
list($host, $port) = explode("::", $hosts[$index]);
else{
$host = $hosts[$index];
$port = $this->Port;
}

I can then send email via SMTP without having to change the PHP defaults, using the phpmailer properties/functions as intended

$mail = new PHPMailer();
$mail->SetLanguage( 'en', '/usr/share/php/libphp-phpmailer/language' );
$mail->Host = "ssl://smtp.gmail.com::465";
$mail->IsSMTP(); // send via SMTP
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "gmail_user_name@gmail.com"; // SMTP username
$mail->Password = "password"; // SMTP password
$webmaster_email = "martinwalker@gmail.com"; //Reply to this email ID
$email="an_email@hotmail.com"; // Recipients email ID
$name="to name"; // Recipient's name
$mail->From = $webmaster_email;
$mail->FromName = "from name";
$mail->Subject="Charlie says ....";
$mail->AddAddress($email,$name);

etc, etc

Note : I can now use

$mail->Host="ssl://smtp.gmail.com::465";

(note particularly '::' followed by port)

This fix leaves me free to decide how I send email in my code - the gotcha is that if I use any SMTP server, and specify the full string, I will need to use '::' followed by the port number.

Don't try this if it doesn't make perfect sense, keep a copy of your original class.phpmailer.php file just in case you go off course and need to return to you original set up.

MW

March 16, 2009 5:57 AM  
Anonymous nile said...

I get this error. "SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host. " I already put this:

include "class.phpmailer.php";
include "class.smtp.php";

$mail=new PHPMailer();

Please help me to fix it?

April 09, 2009 3:28 PM  
Anonymous Anonymous said...

anybody can help this problem.
Warning: fsockopen() [function.fsockopen]: unable to connect to http://smtp.gmail.com:465 (Unable to find the socket transport "http" - did you forget to enable it when you configured PHP?) in C:\xampp\htdocs\chris\v17\class.smtp.php on line 122
Mailer Error: SMTP Error: Could not connect to SMTP host.

May 20, 2009 3:23 PM  
Blogger abani said...

Can we retrieve mails in PHP

May 23, 2009 8:43 AM  
Anonymous Anonymous said...

Hello,

It works perfectly !
Just edit your php.ini and uncomment the openssl.dll.

Next, just copy the 3 class files in your work directory.

After that create an object PHPMailer() by including("class.phpmailer.php") in your php file.

Very easy with phpmailer,
Thank you for this topic.

Regards,

May 23, 2009 8:03 PM  
Blogger Matthew said...

Steo 6 is wrong:

Paste this code
$host = "ssl://smtp.gmail.com";
$port = 465;
before the line 104 #connect to the smtp server
Hint: Search for #connect

You should be using the built in property: SMTPSecure as in:
$mail->SMTPSecure = "ssl";

Doing this appends the 'ssl://' to your 'smtp.gamil.com'

Though perhaps this is only in the newest versions.

Hope this helps others.

June 19, 2009 6:23 AM  

Post a Comment

Links to this post:

Create a Link