configure php mail code example
Example 1: how to setup php mailer
<?php
include "emails/PHPMailer/PHPMailerAutoload.php";
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->IsHTML(true);
$mail->Username = "@gmail.com";
$mail->Password = "";
$mail->setFrom('[email protected]', 'Zubair Mushtaq');
$mail->addReplyTo('[email protected]', 'Secure Developer');
$mail->addAddress('[email protected]', 'Abulogicss');
$mail->Subject = 'PHPMailer SMTP test';
$mail->msgHTML("convert HTML into a basic plain-text alternative body");
$mail->AltBody = 'This is a plain-text message body';
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
Example 2: config mail php
<?php
$to = "[email protected], [email protected]";
$subject = "This is a test HTML email";
$message = "
<html>
<head>
<title>This is a test HTML email</title>
</head>
<body>
<p>Test email. Please ignore.</p>
</body>
</html>
";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: <[email protected]>' . "\r\n";
$headers .= 'Cc: [email protected]' . "\r\n";
mail($to,$subject,$message,$headers);
?>