With SMTP authentication, you can send email via PHP. You just have to download PHPMailer class files to use the PHPMailer courses:
The following is the sample code for SMTP authentication to send e-mails using the PHP script:
$mail->Host = “mail.domain.com”; // SMTP servers
$mail->SMTPSecure = ‘ssl’; // Enable SSL encryption, then change below port to 587.
You may remove this line to use non-SSL with port 25 or 26 in below.
$mail->Port = “25”; //specify SMTP Port
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = “email@domain.com”; // SMTP username
$mail->Password = “password”; // SMTP password
$mail->From = “email@domain.com”;
$mail->FromName = “Name”;
$mail->AddAddress(“Recipient@emailaddress.com”,”Name”);
$mail->AddReplyTo(“yourname@domain.com”,”Your Name”);
$mail->WordWrap = 50; // set word wrap
$mail->IsHTML(true); // send as HTML
$mail->Subject = “Here is the subject”;
$mail->Body = “This is the HTML body“;
$mail->AltBody = “This is the text-only body”;
if(!$mail->Send())
{
echo “Message was not sent
“;
echo “Mailer Error: ” . $mail->ErrorInfo;
exit;
}
echo “Message has been sent”;
?>
Please ensure that you make needed modifications to the above script.
Note: Our mail servers require your SMTP authentication script to submit email for safety reasons.