Reputation: 619
I'm looking to record the SMTP transaction for each sent email in laravel 4.1.
For example when I use the following code to send an email:
Mail::send('emails.any_view', $data, function($message) use ($user) {
$message->from('[email protected]', 'PHP Code');
}
I would like to see something like:
[Resolving gmail-smtp-in.l.google.com...]
[Contacting gmail-smtp-in.l.google.com [173.194.64.27]...]
[Connected]
220 mx.google.com ESMTP zd4si6046704obb.40 - gsmtp
EHLO Network-Tools.com
250-mx.google.com at your service, [67.222.132.193]
VRFY test
252 2.1.5 Send some mail, I'll try my best zd4si6046704obb.40 - gsmtp
RSET
250 2.1.5 Flushed zd4si6046704obb.40 - gsmtp
EXPN test
502 5.5.1 Unimplemented command. zd4si6046704obb.40 - gsmtp
RSET
250 2.1.5 Flushed zd4si6046704obb.40 - gsmtp
MAIL FROM:<[email protected]>
250 2.1.0 OK zd4si6046704obb.40 - gsmtp
RCPT TO:<[email protected]>
550-5.1.1 The email account that you tried to reach does not exist. Please try
550-5.1.1 double-checking the recipient's email address for typos or
550-5.1.1 unnecessary spaces. Learn more at
550 5.1.1 http://support.google.com/mail/bin/answer.py?answer=6596 zd4si6046704obb.40 - gsmtp
[Address has been rejected]
RSET
250 2.1.5 Flushed zd4si6046704obb.40 - gsmtp
QUIT
221 2.0.0 closing connection zd4si6046704obb.40 - gsmtp
[Connection closed]
I don't really care if this is in a log file or variable I can just dump when I need to. does anyone know how I can access this information?
I think I'm getting closer to my answer. If I replace the encription in app/config/mail.php to something invalid I get an error message like:
Swift_TransportException Expected response code 220 but got code "500", with message "500 5.5.1 Unknown or unimplemented command "
I need a way of accessing the response codes even when they do not create an error.
Upvotes: 0
Views: 3519
Reputation: 449
I was getting the same error.. It is working fine when i changed EMAIL_ENCRYPTION in mail.php. It was 'encryption' => env('MAIL_ENCRYPTION', 'tps'), before I change it to 'encryption' => env('MAIL_ENCRYPTION', ''),
Upvotes: 0
Reputation: 41756
Laravel Mail itself does not provide these details.
There is only the Log functionality, which writes all e-mails to your log files and does not send them to recipients. This is mainly for debugging and email content verification.
Mail::send() uses the configured mail daemon, which is your server or a remote server.
If you are using a remote, like Gmail, as SMTP server, you will not get access to these log details.
If it is you own server, go to the configured logs dir and catch the relevant log file.
When you have determined the file, use PHP to read it or tail -f /var/log/maillog
.
echo file_get_contents('/var/log/maillog');
:)
Upvotes: 1