开发者

Generate email to file without sending

开发者 https://www.devze.com 2023-01-13 06:43 出处:网络
I want to generate an email using the mail() function: <?php $to= \'nobody@example.com\'; $subject = \'the subject\';

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消