Generate email to file without sending
I want to generate an email using the mail()
function:
<?php
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
// instead of sending mail, out put to file
mail($to, $subject, $message, $headers);
?>
But instead of having it actually send the email, I want it to output the email to file with all of the headers etc. as开发者_开发百科 a mail server would see it.
With SwiftMailer you can use plugin: http://swiftmailer.org/wikidocs/v3/plugindev/sendevent
We use the Zend_Mail library and have different transports for destination (SMTP, STDOUT, file, etc.). Just in case that's an option, here's some information on Zend_Mail transports.
精彩评论