Skip to content

Instantly share code, notes, and snippets.

@pluveto
Forked from MikeiLL/phpmailer simple test
Created January 29, 2022 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pluveto/c72aa77d58c16181d80339654e54177d to your computer and use it in GitHub Desktop.
Save pluveto/c72aa77d58c16181d80339654e54177d to your computer and use it in GitHub Desktop.
<?php
require_once('../lists/admin/PHPMailer/PHPMailerAutoload.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer();
$body = file_get_contents('contents.html');
$body = eregi_replace("[\]",'',$body);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.madhappy.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->SMTPSecure = "tls"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 587; // set the SMTP port for the GMAIL server
$mail->Username = "email"; // GMAIL username
$mail->Password = "password"; // GMAIL password
$mail->SetFrom('mike@email.com', 'Mike iLL');
$mail->AddReplyTo('mike@email.com', 'Mike iLL');
$mail->Subject = "PHPMailer Test Subject via smtp (Gmail), basic";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$address = "mike@another.com";
$mail->AddAddress($address, "First Last");
//$mail->AddAttachment("images/phpmailer.gif"); // attachment
//$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment