1 | Download PHPMailer from http://phpmailer.sourceforge.net | |||||||
2 | Extract to folder phpmailer | |||||||
3 4 5 6 | Create a file email.php Paste this code and change the values in blue as you need (I modified the sample code given on the PHPMailer homepage) NOTE: Change all XXX as your user name and YYY as your password. include_once("phpmailer.class.php"); $mail = new PHPMailer(); $mail->IsSMTP(); // enable SMTP authentication $mail->SMTPAuth = true; // sets the prefix to the server $mail->SMTPSecure = "ssl"; // sets GMAIL as the SMTP server $mail->Host = "smtp.gmail.com"; // set the SMTP port $mail->Port = "465"; // GMAIL username $mail->Username = "XXX@gmail.com"; // GMAIL password $mail->Password = "YYY"; $mail->From = "email address who send the email"; $mail->FromName = "rajmaha"; $mail->AddReplyTo("startwpnow@gmail.com", "name to reply"); $mail->Subject = "Test Gmail!"; $is_your_mail_an_html = ""; $text_message = "hai"; if($is_your_mail_an_html){ $mail->MsgHTML($html_message); $mail->IsHTML(true); }else{ $mail->Body = $text_message; $mail->IsHTML(false); } $mail->AddAddress("startwpnow@gmail.com", "to name"); if(!$mail->Send()){ echo $mail->ErrorInfo; }else{ $mail->ClearAddresses(); $mail->ClearAttachments(); } NOTE: don't forget to include the "phpmailer.class.php" and "class.smtp.php". Unable to find the socket transport “ssl” - did you forget to enable it when you configured PHP? Here is the solution to the above problem, uncommented the line in php.ini ;extension=php_openssl.dll php.ini files location C:\wamp\bin\php\php5.3.5\php.ini C:\wamp\bin\apache\Apache2.2.17\bin\php.ini Question? Answer: startwpnow@gmail.com |
Thursday, 27 January 2011
Send email from my localhost wamp server.
Subscribe to:
Posts (Atom)