A More Reliable PHP Send-Mail Function

If you have Qmail installed on your web server then this simple lightweight mail function using PHPs native mail() works nicely.

If you wanted to use SMTP and something a little "heavier" for some hardcore mailing then check out the SwiftMailer class

<?php
function send_mail($mail_to)
{
putenv ("QMAILUSER=myuser");
putenv ("QMAILNAME=My Name");
putenv ("QMAILHOST=mydomain.com");

$headers = 'From: My Name <myname@mydomain.com>' . "\r\n" .
'Reply-To: My Name Nostin <myname@mydomain.com>' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

$subject = "Testing email";
$body = "This mail is a test, no response required.";
$err = mail($mail_to, $subject, $body, $headers);
return $err;
}
?>
Comments (0)
+ –