Find jobs - Debt Consolidation - Debt Consolidation - Debt Consolidation - Debt Consolidation

PDA

View Full Version : is this function an effecient way to send mail?


rlynch
Aug 9th 2006, 3:21 pm
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;
}

clancey
Aug 9th 2006, 3:48 pm
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.

webviz
Aug 9th 2006, 9:29 pm
<?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;
}

?>

casper
Aug 10th 2006, 6:56 am
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.

talentcoder
Aug 11th 2006, 3:50 am
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.

ravianz
Aug 11th 2006, 4:04 am
mail function dewscribed by clancey is perfect and i have been using it in same way for a long time!