Kirim Email Dengan PHPMailer Di Wamp Server


Kebutuhan

1. WAMP Server
2. PHPMailer_5.2.4

Konfigurasi

1. Enable Module php_openssl di wamp
2. Buat directory c:\wamp\www\phpmailer
3. PATH PHPMailer_5.2.4 ke dalam phpmailer yang telah di buat
4. Buat index.php isi dengan konfigurasi di bawah ini :

<?php
error_reporting(E_ALL);
require("PHPMailer_5.2.4/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->SMTPDebug  = 2; 
$mail->From = "yourmail@gmail.com";
$mail->FromName = "Your Name";
$mail->Host = "smtp.gmail.com"; // specif smtp server
$mail->SMTPSecure= "ssl"; // Used instead of TLS when only POP mail is selected
$mail->Port = 465; // Used instead of 587 when only POP mail is selected
$mail->SMTPAuth = true;
$mail->Username = "yourmail@gmail.com"; // SMTP username
$mail->Password = "yourpassword"; // SMTP password
$mail->AddAddress("yourmail@gmail.com", "My Name"); //replace myname and mypassword to yours
$mail->AddReplyTo("yourmail@gmail.com", "My Name"); 
$mail->WordWrap = 50; // set word wrap //$mail->AddAttachment("c:\\temp\\js-bak.sql"); // add attachments //$mail->AddAttachment("c:/temp/11-10-00.zip"); 
$mail->Subject = 'Mail Test'; $mail->Body = 'Hanya Test Sent mail aja '; 
if($mail->Send()) 
{
echo "Send mail successfully";
} 
else 
{
echo "Send mail fail";
} 
?>

Apabila di success setingan nya ketika di execute scriptnya makan output di browser kamu akan seperti ini

SMTP -> FROM SERVER:220 smtp.gmail.com ESMTP uy1sm4832532pac.39 – gsmtp
SMTP -> FROM SERVER: 250-smtp.gmail.com at your service, [115.124.94.129] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8
SMTP -> FROM SERVER:250 2.1.0 OK uy1sm4832532pac.39 – gsmtp
SMTP -> FROM SERVER:250 2.1.5 OK uy1sm4832532pac.39 – gsmtp
SMTP -> FROM SERVER:354 Go ahead uy1sm4832532pac.39 – gsmtp
SMTP -> FROM SERVER:250 2.0.0 OK 1449066782 uy1sm4832532pac.39 – gsmtp
SMTP -> FROM SERVER:221 2.0.0 closing connection uy1sm4832532pac.39 – gsmtp
Send mail successfully

Kalo send mail error biasanya ada port yang di tutup sama ISP kamu, atau juga butuh restart apache nya karena mungkin ketika setting php_openssl belom di restart.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s