an alternative for the mail sender (General)
Hello
the my_mail function does not work in my host, ...
You are not the first who reported this.
Some comments (as comments):
function my_mail($TOMail, $TOTitle, $TOContent, $FromName, $SmtpServer="smtp.xxx.com", $From="users@xxx.com", $FromUser="users@xxx.com", $FromPass="*******") { /** * The variables $From and $FromUser have the same content. * These variables can have different content? * Otherwise they are redundant. */ $jmail=new COM("JMail.Message")or die("Failed to call the Jmail class!"); /* die is bad, use a return (like $errorMessage) instead */ $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; }
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.
So there is a control structure needed. Maybe something like if ($jmail === true) {...} else {...}
.
Tschö, Auge
--
Trenne niemals Müll, denn er hat nur eine Silbe!