Cara Mengirim Email Menggunakan PHPmailer Dan Gmail
Apa yang harus Dilakukan ?
- Mengaktifkan Less Secure Apps Gmail
- Membuat Script Pengiriman PHPMailer
- Download full script disini >> DOWNLOAD
Cara Mengaktifkan Less Secure Apps Gmail
#2 Kedua, Aktifkan Less Secure Apps melalui dengan akses link berikut Less Secure Apps atau Disini.
#3 Ketiga, Ubah status menjadi ON.
Membuat Script Kirim Email PHPMailer
<html>
<head>
<title></title>
</head>
<body>
<h2>Kirim Email</h2>
<form method=”POST” action=”kirim.php”>
<table>
<tr>
<td>Nama :</td>
<td><input type=”text” name=”nama” size=”30″></td>
</tr>
<tr>
<td>Email :</td>
<td><input type=”email” name=”email” size=”30″></td>
</tr>
<tr><td>Subjek :</td>
<td><input type=”text” name=”subjek” size=”30″></td>
#3 Ketiga, buat file kirim.php pada folder website bapak. Dan isikan script php mailer berikut :
<?php
use PHPMailerPHPMailerPHPMailer;
use PHPMailerPHPMailerException;
require_once “library/PHPMailer.php”;
require_once “library/Exception.php”;
require_once “library/OAuth.php”;
require_once “library/POP3.php”;
require_once “library/SMTP.php”;
$mail = new PHPMailer;
//Enable SMTP debugging.
//$mail->SMTPDebug = 3;
//Set PHPMailer to use SMTP.
$mail->isSMTP();
//Set SMTP host name
$mail->Host = “tls://smtp.gmail.com”; //host mail server
//Set this to true if SMTP host requires authentication to send email
$mail->SMTPAuth = true;
//Provide username and password
$mail->Username = “temailanda@gmail.com”; //nama-email smtp
$mail->Password = “password-gmail”; //password email smtp
//If SMTP requires TLS encryption then set it
$mail->SMTPSecure = “ssl”;
//Set TCP port to connect to
$mail->Port = 587;
$mail->From = “temailanda@gmail.com”; //email pengirim
$mail->FromName = “Ini adalah PHPmailer”; //nama pengirim
$mail->addAddress($_POST[’email’], $_POST[‘nama’]); //email penerima
$mail->isHTML(true);
$mail->Subject = $_POST[‘subjek’]; //subject
$mail->Body = $_POST[‘pesan’]; //isi email
$mail->AltBody = “PHP mailer”; //body email
if(!$mail->send())
{
echo “Mailer Error: ” . $mail->ErrorInfo;
}
else
{
echo “Message has been sent successfully”;
}
?>
#5 Kelima, Selamat PHPmailer telah berhasil dibuat. Pada panduan kali ini PHPmailer sudah di intergrasikan dengan form dan gmail. Karena tidak dapat melakukan copy script, silakan untuk langsung download scriptnya dibawah.