In development and QA, i'd like to record the Mail object's transaction history to a DB table, but am unsure as to how to go about accessing the data for the class. At the moment i do not want to log to a static file.
It's particularly useful for tracing emails - a lot of users experience problems when doing password resets etc because their provider (Hotmail, Gmail) marks the mail as spam, meaning i get a lot "i never got the email it was supposed to send" messages. Looking it up in the DB means i can see directly that the email was sent successfully, and the problem lies with them, not on the server-side. Equally, it helps debug SMTP errors.
// try/catch block {
Mail::send('emails.any_view', $data, function($message) use ($user) {
$message->from('server@example.com', 'PHP Code');
$message->to($user->email);
$message->subject($subject);
// logging code here, e.g.
/*
If( Config::get('record_smtp') ) {
$record = new MailRecord;
$record->to = $user->email; //(or id)
$record->subject = $subject;
$record->body = $message->getBody(); //(not sure if that's correct)
$record->result = 1; //(or 0 if it goes wrong)
$record->smtp_transaction = $message->isThereAMethodToGetThis();
$record->save();
}
*/
});
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community