Plugins ini tidak akan berguna bila websites anda tidak ditambahkan anti-spam, silahkan tambahkan anti-spam terlebih dahulu.
Dalam artikel ini email dianggap sudah ada dengan user dan password yang benar, bila belum ada silahkan didaftarkan mengikuti artikel berikut.
- Download PHPMailer di http://phpmailer.worxware.com
- ekstract ke websites misalnya ke folder phpmailer
- buka script php yang mengirimkan email dan modifikasi.
- tambahkan kode:
require_once('phpmailer/class.phpmailer.php'); - Pastikan lokasi foldernya benar dengan menyesuaikan folder yang dibuat.
- Sesuaikan form anda dengan kode dibawah misalnya subject, body, mailform, dll.
contoh modifikasi:
require_once('phpmailer/class.phpmailer.php');
$mail = new PHPMailer();
$body = file_get_contents('contents.html');
$body = eregi_replace("[\]",'',$body);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.yourdomain.com"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "mail.yourdomain.com"; // sets the SMTP server
$mail->Port = 587; // set the SMTP port
$mail->Username = "yourname@yourdomain"; // SMTP account username
$mail->Password = "yourpassword"; // SMTP account password
$mail->SetFrom('name@yourdomain.com', 'First Last');
$mail->AddReplyTo("name@yourdomain.com","First Last");
$mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$address = "whoto@otherdomain.com";
$mail->AddAddress($address, "John Doe");
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
contoh Konfigurasi gmail:
SMTP Host: smtp.gmail.com
SMTP Port: 465
Username : alamat email lengkap contoh username@gmail.com
Password : password email
contoh Konfigurasi mail yahoo:
SMTP Host: smtp.mail.yahoo.com
SMTP Port: 465
Username : alamat email lengkap contoh username@yahoo.com
Password : password email
contoh Konfigurasi outlook.com:
SMTP Host: smtp-mail.outlook.com
SMTP Port: 587
Username : alamat email lengkap contoh username@outlook.com
Password : password email
No comments:
Post a Comment