tags:

views:

43

answers:

2

I want to generate an email using the mail() function:

<?php
$to      = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n" .
    'Reply-To: [email protected]' . "\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. Is this possible?

A: 

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.

Inkspeak
This pushed me in the right direction. Since I use cake, I was able to use the 'debug' output method on the email component and pull the email information from the session. Thanks!
cdburgess
+1  A: 

With SwiftMailer you can use plugin: http://swiftmailer.org/wikidocs/v3/plugindev/sendevent

FractalizeR
This looks interesting. Thanks for the suggestion. I will review this in a little more depth.
cdburgess
@cdburgess Welcome.
FractalizeR