Most Linux hosting doesn’t allow direct mail sending through PHP mail() function due to spam security issue. In order to send email through PHP mail() function, you need to be authenticate first by the SMTP server. Simplest way to do is to use the PHPMailer. Below is the sampleĀ php code using PHPMailer.
<?php
include(”class.phpmailer.php”);
$mail = new PHPMailer();
$mail-> IsSMTP();
$mail->Host = “mail.yourdomain.com”;
$mail->SMTPAuth = true;
$mail->Username = “youruseremail@yourdomain.com”;
$mail->Password = “yourpassword”;
$mail->From = “youremail@yourdomain.com”;
$mail->FromName = “YourName”;
$mail->AddAddress($To-EmailAddress);
$mail->AddReplyTo(”youremail@yourdomain.com”, “YourName”);
$mail->IsHTML(true);
$mail->Subject = “subject is here”;
$mail->Body = “full body message here”;
$mail->AltBody = “full body message same here”;
if(!$mail->Send())
{
$Confirm = “Error in sending! Message hasn’t been sent”;
}
else
{
$Confirm = “Message has been sent”;
}
?>

September 22nd, 2008 at 7:40 am
thanks for this tutorial, it has helped me a lot
October 30th, 2008 at 3:16 pm
Does this mean I can’t send mails anymore through PHP with my Linux Minipack Hosting account?
November 12th, 2008 at 9:44 pm
Hi Daniel, this articles explains how to send email PHP through Linux hosting