Send email using Gmail and PHP
This is really useful if you don’t have an email server.
Using your Gmail account for sending emails is great ;)
Steps:
- Dowload the latest version of PHPmailer class
- Include it in your script
- Test with this code:
$mail = new PHPMailer(); $mail->IsSMTP(); //GMAIL config $mail->SMTPAuth = true; // enable SMTP authentication $mail->SMTPSecure = "ssl"; // sets the prefix to the server $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server $mail->Port = 465; // set the SMTP port for the GMAIL server $mail->Username = "gmailusername"; // GMAIL username $mail->Password = "gmailpassword"; // GMAIL password //End Gmail $mail->From = "from@email.com"; $mail->FromName = "you name"; $mail->Subject = "some subject"; $mail->MsgHTML("the message"); //$mail->AddReplyTo("reply@email.com","reply name");//they answer here, optional $mail->AddAddress("address@to.com","name to"); $mail->IsHTML(true); // send as HTML if(!$mail->Send()) {//to see if we return a message or a value bolean echo "Mailer Error: " . $mail->ErrorInfo; } else echo "Message sent!";
- Free SMS Notification for high server load
- Prevent spam in your PHP site with akismet
- How to Tweet from PHP and short Url with bit.ly
- Custom Error for WordPress
- Open Classifieds 1.7. Release Candidate 1
- How to enlist Gmail to sell your Craigslist items for you
- I WON! I WON! (And Imagine, I Never Even Entered!)
- Finovate Startup 2009 Live Twitter
- All That You Needed To Understand About Html
- Setting up Google apps email services for your own domain: Free customized mailboxes for your own domain
Help sharing and Flatter me ;)

I used the code but i got the following error. what could be the probable reason. the internet connection is up and running while i am using this script..Please help..
Error:
SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host.
Maybe a problem with you hosting, port closed or something like that