ALTERNATIF 1 / MODEL SCRIP 1
- Meletakkan libarary “PHPMailer” di folder yang diinginkan, misalnya phpmailer/class.phpmailer.php
- Membuat script eksekusi kirim emailnya
<?php
require_once('phpmailer/class.phpmailer.php'); //memanggil library php mailernya
define('GUSER', 'username email’); //username email
define('GPWD', 'password email'); // password email
function smtpmailer($to, $from, $from_name, $subject, $body) {
global $error;
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 2; // untuk memunculkan pesan error /debug di layar
$mail->SMTPAuth = true; // authentifikasi smtp enable atau disable
$mail->SMTPSecure = 'ssl atau di kosongkas jika none'; // secure transfer membutuhkan authentifikasi dari mail server
$mail->Host =’hostname email’; // masukkan nama host email "diawal ssl://"
$mail->Port = nomer port; //port secure ssl email
$mail->Username = 'username email'; //username email
$mail->Password = 'password email'; //password email
$mail->SetFrom($from, $from_name);
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AddAddress($to);
if(!$mail->Send()) {
$error = 'Mail error: '.$mail->ErrorInfo;
return false;
} else {
$error = 'Message sent!';
return true;
}
}
smtpmailer('email tujuan', 'email pengirim', 'nama pengirm', 'header email', 'isi email'); // scrip kirim email
Demikian script pengiriman email dengan authentifikasi SMTP. Link downloadnya : https://www.mediafire.com/?fa8ckmqfqb406bz
ALTERNATIF 2 / MODEL SCRIPT 2
- Meletakkan libarary “PHPMailer” di folder yang diinginkan, misalnya class/class.phpmailer.php
- Membuat script eksekusi kirim emailnya
<?php
include "classes/class.phpmailer.php";
$mail = new PHPMailer;
$mail->IsSMTP();
$mail->SMTPSecure = 'ssl';
$mail->Host = "smtp.bizmail.yahoo.com"; //host
$mail->SMTPDebug = 2;
$mail->Port = 465;
$mail->SMTPAuth = true;
$mail->Username = "xxx@xxx.net"; //user email
$mail->Password = "xxxx"; //password email
$mail->SetFrom("xxx@xxx.net","IT System Support"); //set email pengirim
$mail->Subject = "Testing"; //subyek email
$mail->AddAddress("aaa@aaaa.net","Anang Pradani P"); //tujuan email
$mail->MsgHTML("Testing...");
if($mail->Send()) echo "Message has been sent";
else echo "Failed to sending message";
?>
Keterangan untuk SetFrom dan Username harus sama.
Donwload disini filenya
Tidak ada komentar:
Posting Komentar