an alternative for the mail sender (General)

by chengtr, Tuesday, December 07, 2010, 13:56 (4892 days ago)
edited by chengtr, Tuesday, December 07, 2010, 14:46

the my_mail function does not work in my host, I used Jmail to make a alternative function to do the job. that's as below,

function my_mail($TOMail,$TOTitle,$TOContent,$FromName,$SmtpServer="smtp.xxx.com",
$From="users@xxx.com",$FromUser="users@xxx.com",$FromPass="*******")
{
$jmail=new COM("JMail.Message")or die("Failed to call the Jmail class!");
$jmail->charset= "utf-8";
$jmail->logging="true";
$jmail->ContentType = "text/html";
$jmail->From=$From;
$jmail->FromName=$FromName;
$jmail->AddRecipient($TOMail);
$jmail->Subject=$TOTitle;
$jmail->Body=$TOContent;
$jmail->MailServerUserName=$FromUser;
$jmail->MailServerPassword=$FromPass;
$jmail->Send($SmtpServer);

return true;

}

Use this function to replace the one in the file of function.inc.php under includes directory.

BUT LOOK OUT, this function will return false for any result, so we can not know whether the mail has been sent successfully.
And in fact, if the $TOMail is a valid e-mail address, it would be a success! So we need add "return true; " at the end of the function.

I found it works smoothly! :)


Complete thread:

 RSS Feed of thread