December 18, 2009

Error Sending mails as nobody user

Cause : Usually caused whenever the option "Prevent nobody user to send mails" is Enabled from WHM -> Tweak Settings

Resolution :
(i) You may disable the above specified option, however it is depended on the Server Owners Policies
(ii) Its possible to recode the code to send mails using SMTP . Code given below :



";
$to = "TargetName ";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$host = "mail.mailserver.com";
$username = "name@myemail.com";
$password = "my_password";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("

" . $mail->getMessage() . "

");
} else {
echo("

Message successfully sent!

");
}
?>



Ensure that the following PEAR packages are installed :
pear install Mail;pear install Net_SMTP;pear install Auth_SASL;

No comments:

Post a Comment