Created
August 29, 2016 14:40
-
-
Save ferdhie/be99ad96e72e26c147ec47926059c326 to your computer and use it in GitHub Desktop.
PHPMailer usage example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//https://github.com/PHPMailer/PHPMailer | |
require 'class.phpmailer.php'; | |
require 'class.smtp.php'; | |
$mail = new PHPMailer(); | |
$mail->CharSet = 'UTF-8'; | |
$mail->IsSMTP(); | |
$mail->SMTPDebug = 1; | |
$mail->Host = 'smtp.gmail.com'; | |
$mail->Port = 587; | |
$mail->SMTPSecure = 'tls'; | |
$mail->SMTPAuth = true; | |
$mail->SMTPKeepAlive = true; // SMTP connection will not close after each email sent, reduces SMTP overhead | |
//account gmail harus dienable dulu sebeluumnya utk menggunakan TLS AUTH | |
//http://www.google.com/settings/security/lesssecureapps | |
$mail->Username = "[email protected]"; | |
$mail->Password = "password"; | |
$mail->SetFrom('[email protected]', 'Full Name'); | |
$mail->Subject = "Subject Email"; | |
$mail->AddAddress('[email protected]', 'Destination User'); | |
$mail->MsgHTML("<p>Hello World</p>"); | |
$mail->AltBody = "Plaintext body"; | |
$mail->Send(); | |
$mail->SmtpClose(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment