Skip to content

Instantly share code, notes, and snippets.

@ferdhie
Created August 29, 2016 14:40
Show Gist options
  • Save ferdhie/be99ad96e72e26c147ec47926059c326 to your computer and use it in GitHub Desktop.
Save ferdhie/be99ad96e72e26c147ec47926059c326 to your computer and use it in GitHub Desktop.
PHPMailer usage example
<?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