function sendEmail($To, $From, $Subject, $Body) { global $set_ini_smtp, $quiet,$from_address_mail; mail("$To", "$Subject","$Body","From: $From <$From>\nX-Mailer: PHP 4.x\r\n\r\n"); return true; }
You are just doing a minor rewrite of the PHP mail function. I do not understand why you are including the globals. Unless you intend to use them you do not need them. I also question adding the X-Mailer bit and the extra newlines. By putting in two newlines you are forcing everything below that line to be part of the email message body and NOT the header. I would just use: function sendEmail($To, $From, $Subject, $Body) { mail($To, $Subject, $Body, "From: $From"); return true; } Less is better in email headers.
<?php function send_email($to, $subject, $message, $headers) { // you may care to do some regex to filter out any sent shit mail($to, $subject, $message, $headers); return true; } ?> PHP:
I use SourceForge phpmailer. I own a mailform processor and I noticed that the mail function didn't always send my emails out when sending loads of emails.
The function mail() just puts your email in the queue of mail server (MTA). When your email will be sent out depends on how the queue is running. So the most effecient way of sending mail is to run the queue frequently. It doesn't matter how you code in PHP.