Web Development

PHPMailer with PHP Send Mail

As I already posted earlier, PHP has several methods to send the mail. In this post I am going to cover the send mail using PHP Send mail.

Earlier I have posted about the send mail using SMTP with PHPMailer. Before this I have posted about the send mail using SMTP with core PHP.

For sending the mails using this method we need to set [code]sendmail_path[/code] in php.ini.

Now let’s see how to send mail using SendMail using PHPMailer.

PHPMailer with SendMail

[cc lang=”php”]
IsSendmail();
// Above line does the all trick

// Set the body
$body = file_get_content(“body.html”);

// Add Reply To
$mail->AddReplyTo(“[email protected]”,”Reply To”);

// Add From
$mail->SetFrom(“[email protected]”, “From”);

// Add To Address
$address = “[email protected]”;
$mail->AddAddress($address, “To Mail”);

// Add the subject
$mail->Subject = “PHPMailer Test via Sendmail”;

// Set the mail to be send as HTML
$mail->MsgHTML($body);

// Send the mail Finally
if(!$mail->Send())
{
echo “Mailer Error: ” . $mail->ErrorInfo;
}
else
{
echo “Message sent!”;
}
?>
[/cc]

Note: [code]$mail->IsSendmail()[/code] is doing all the trick here.

Shares:
  • sunil
    November 5, 2011 at 5:17 pm

    please provide me phpmail as soon as possible.
    thanks

    Reply
  • KM Srinivas
    KM Srinivas
    July 17, 2015 at 8:39 pm

    Hi Avinash, I’m getting an error on my wordpress website like “Could not execute: /usr/sbin/sendmail”.
    My plan is Ultimate and all sub domain websites also geting the same error. I am using wordpress for all mu sub domains. can you tell me any solution.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *