How Do I keep mail() from waiting for confirmation (true)
i have a php script that sends out my messages using mail(). the problem is that it waits until it receives confirmation from the mailer before it continues... I'd like to skip this step. is there a way to set it as true by default or have it not wait, etc? below is the section of code I'm referring to. Thanks.
if (file_exists($attachment)) {
sendmail_attach_new($email, $subject, $msg_text, $msg, $attachment, $mailheaders, "$from_name <$from_email>");
} elseif ($msg) {
if( ini_get('safe_mode') ){
mail($email, $subject, $msg, $mailheaders);
}else{
mail($email, $subject, $msg, $mailheaders, "-f$from_email");
}
} elseif ($msg_text) {
if( ini_get('safe_mode') ){
mail($email, $subject, $msg_text, $mailhead开发者_Go百科ers);
}else{
mail($email, $subject, $msg_text, $mailheaders, "-f$from_email");
}
}
//update the mailing list for confirmation of sent mail
$sql = "update $tableMail set mid ='$mid' where id='$DATA[id]'";
sql_query($sql);
$logbuffer .= "Mailed: $email<br>";
$row++;
}
Your can write to stack mails that your must send, and script running by cron, can send it
Short answer: No.
Btw, don't make your scripts `safe_mode compatible. Any host that still uses this deprecated mis-feature should be avoided anyway.
You can externalize your mail sending code to a separate php script and call that script using exec() function, something like this on Unix platforms:
exec ("/usr/bin/php send-mail.php \"$from\" \"$to\" \"$subject\" \"$message\" >/dev/null &");
To make this background process execution platform independent use code like this:
function launchBackgroundProcess($commandLine) {
// Windows
if(PHP_OS == ‘WINNT’ || PHP_OS == ‘WIN32′) {
pclose(popen(’start /b ‘.$commandLine.”, ‘r’));
}
// Some sort of UNIX
else {
pclose(popen($commandLine.‘ > /dev/null &’, ‘r’));
}
return true;
}
Refer to this Blog post: http://w-shadow.com/blog/2007/10/16/how-to-run-a-php-script-in-the-background/
精彩评论