Due to the amount of requests emailed to me for working source code I have now posted the modified PHPMailer I use in my own projects. Click here to download the library. Here’s an example of how to use the code:
require_once('/phpgmailer/class.phpgmailer.php');
$mail = new PHPGMailer();
$mail->Username = 'user@domain.com';
$mail->Password = 'password';
$mail->From = 'user@domain.com';
$mail->FromName = 'User Name';
$mail->Subject = 'Subject';
$mail->AddAddress('myfriend@domain.com');
$mail->Body = 'Hey buddy, here's an email!';
$mail->Send();
This will work for any GMail or Google Hosted email account. Just make sure to include the @domain.com part for the username, even if it’s for standard GMail. Hope this saves people some hastle.
[tags]gmail, php, google, phpmailer[/tags]
Tags: 93 Comments
i have a problem like this and i need help.
here is the error code
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:\Program Files\Apache Group\Apache2\htdocs\yeniproje\class.smtp.php on line 105
I am fu %$#$%^ &&^%^$ madd I have tried 50 user names and gmail won’t take them I want to do something really unchristian HELPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
di
i am getting the following error while running plz help me……
Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\www\DocumentRoot\class.smtp.php on line 1033
I know there hasnt been many ppl answering these questions but i too was having the fsockopen problem. I uncommented the php_openssl adn tried to use this code@
Username = ‘*****@gmail.com’;
$mail->Password = ‘*****’;
$mail->From = ‘*****@gmail.com’;
$mail->FromName = ‘Me’;
$mail->Subject = ‘Test’;
$mail->AddAddress(’*******@hotmail.com’);
$mail->Body = ‘Hey buddy heres an email!’;
if (!$mail->Send()) {
echo “Message was not sent. “;
echo “Mailer Error: ” . $mail->ErrorInfo;
} else {
echo “Message has been sent.”;
}
?>
This time it said message was sent. although no mail was actually recieved! Just hoping someone who has it working may spread a bit more light to the many of us that havent got it working yet.
I am getting the following error sending to yahoo.com via gmail.com very frequently.
SMTP Error: Could not connect to SMTP host.
But sometimes it works. So there is more than just my setup because it has worked but just not all the time. Anyone has similar problem?
TT
Great work. It worked seamlessly with 5 mins of copy paste work. Now I need to send html messages. How to arrange it?
i am getting error code 102 when i log into gmail and its letting me see my gmail but i cand refresh anything
“oops gmail has enountered an error # 102″
i think thats what it says or somthing similar
Thank you for this script, hugely appreciated.
how do make this script in localhost server???????
pleaseeeeeeeeeeeeeeeeeeeeeee
Many Thanks, wish I would have found this earlier; wasted half a day trying to get PEAR::Mail to work.
It’s workin well for me with my gmail account but the problem is that it takes long time to send the email (about 5sec.)
Is it normal? Does someone know a solution to this problem?
Thanks!
I’m with Ted Conn.
the Reply-To has to be set to a different Email address for my application of this mailer… and it seems I can’t change that.
Anyone found a way around this yet?
I use PHPMailer with the following setting. But you have to get the version of PHPMailer that support SMTSecure.
$this->Mailer = “smtp”;
$this->Port = ‘465′;
$this->SMTPSecure = ‘tls’;
$this->SMTPAuth = true;
Once a while I get the following error.
“454 4.7.0 Cannot authenticate due to temporary system problem. Try again later.”
It means that Gmail requires me to manually login to Gmail and type in the verification text to make sure that I am a human. Does anyone have this problem?
One way to get around the 500 email limit is to set up a few Gmail accounts and send the emails using a different account each time. But I am not sure the Google would like that.
All of u guys are genius bt i had problem my mail cant reach on the other side although it show mail sent.
what should i do?
Please help. Thanks
Great script! Love it!
Something is going on with my gmail account. I currently use this script to email the customer a confirmation of his order and the sales people a copy of the order. At 10 pm (give or take), gmail bounced the emails and sent me an email saying that this was spam (mind you, this is only 3 emails sent at a time). When I came in this morning, gmail would not download with Outlook (prompting me for user/pass). When i went to gmail in the browser, it required me to do a captcha. Once I logged in the browser, Outlook started working and the orders started sending email again.
What is going on with this? How can I correct it?
phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in config.inc.php and make sure that they correspond to the information given by the administrator of the MySQL server.
how should i counter this
hi
i wroet mail functionality and if i copy and paste images in that teaxt area they are displaying well
but after sending mail if i checked the mail it comes as a source code
plese send the solution
Thanks ®ards
ashok
At least i solve the problem of sending mail throw gmail using php.the mistake i have done, i modify wrong php.ini file.please first search your php.ini file whatever server you use and make change’s in searched php.ini “file’s” .This is Manaulay doing task.if anyone have dynamick doing task .then please help me providing the php script that all the stuf dynamickly.
Thaks the maker of class phpgmaile. Thanks Sir.
Hi, for some days now my script is giving me some headaches
I want to send congratulation message to any person who registers on my site, however, this script works with most site except for yahoo mail can you pls help figure it out?
Thanks
here is my code
require_once “Mail.php”;
$from=”HSTSMS Account “;
$to=$_POST['email'];
$subject=”Login Information”;
$host=”mail.hstsms.com”;
$port=”25″;
$username=”info@hstsms.com”;
$password=”*********”;
$headers=array(’MIME-Version’=>’1.0′,’Content-Type’=>’text/plain; charset=iso-8859-1′,’From’=>$from,’To’=>$to,’Subject’=>$subject);
$smtp=Mail::factory(’smtp’,array(’host’=>$host,’auth’=>true,
‘username’=>$username,’password’=>$password));
$mail=$smtp->send($to,$headers,$message);
if(PEAR::isError($mail)){
echo(”".$mail->getMessage().”");
print “didnt”;
}else{
header( “Location:../welcom.php”);
exit;
}
I got the code working. One minor detail though: the e-mail shows that it was sent from the…
$mail->Username = ‘user@domain.com’;
…setting, not from the…
$mail->From = ‘user@domain.com’;
Any advice? Is that just a gmail idiosyncrasy?
THIS THING WORKS!!
1. 1st open up your php.ini and uncomment the line called
extension=php_openssl.dll(remove the semicolon from to front)
2. then just use the code mention above in the .php file
For GMAIl
require_once(’/phpgmailer/class.phpgmailer.php’);
$mail = new PHPGMailer();
$mail->Username = ‘user@gmail.com’;
$mail->Password = ‘password’;
$mail->From = ‘user@gmail.com’;
$mail->FromName = ‘User Name’;
$mail->Subject = ‘Subject’;
$mail->AddAddress(’myfriend@domain.com’);//to:email address
$mail->Body = ‘Hey buddy, here’s an email!’;
$mail->Send();
I get this error
Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ) in C:\wamp\www\class.smtp.php on line 105
Any ideas?
Hello!
Is it possible to insert an array in AddAddress instead of only one email adress??
tks
Thank you for your code, it works like a charm !!!
Thanks a lot for the script. It worked instantaneously
I have tried, but not working..
I was experiencing the timeout error.
Turns out the server had the 465 port enabled for incoming connections but not for outgoing connections. This was a firewall setting.
Luckily, a friend of mine is the owner of the company where I host the files, so I asked him if he could enable it for me. After that, it worked like a charm
Great script! Thanks
How to create the class PHPGmailer?
Could no connect to SMTP host
http://www.vulgarisoip.com/files/phpgmailer.zip generates a 404 response. is it possible for you to make this available again?
I used dial-up connection and it sent and delivered mail within 5 seconds. WOW
I am getting this 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 C:\wamp\www\phpgmailer\class.smtp.php on line 105
Did anyone come across this issue?
Nice coding, work for me.
You are a god. Thanks for sharing. I crawled dozens of other forums and nothing working, but simply replacing the files with yours worked out of the box. Cheers.
Dude, thanks a million, this stuff rocks dude. U got any stuff on Wordpress?
rather than complaining please look-into the code
you can find a way if you know php
Great Work, Thank you so much. Worked like a charm, was able to setup the mail function in just few mins after downloading your latest version.
Thanks again and keep up the good work.
Asheesh Prajapati
dasf
Works great! Thank you for sharing this very useful piece of software!
I am using this code. Doing good. But some of the mails are going to SPAM. What is the solution for this ??
Great script!
Thanks!!!
THANK YOU VERY MUCH!!!!!
I’m working in a website and I had some problems with other solutions thath I’ve seen. In good time I google “send mail php gmail” and your webpage have show me the way…
I’ve just make what you said and everything was perfect.
In localhost I couldn’t sent anything but in the webserver just worked fine.
BEAUTIFULLLLLLLLL! THANKS AGAIN!