I am using Sinatra Ruby for API and using Pony gem for sending emails. I want to log status of every mail sent (whether email was successfully sent or not, to whom it was sent etc.). I see only routing log in Sinatra console, but no any sign of email. In short I want to maintain log as in rails console.
Asked
Active
Viewed 76 times
0
-
Look at the Pony gem documentation for how to check the status of mail that is sent. – Kelsey Hannan Jan 12 '21 at 05:00
-
@KelseyHannan i didn't find a way to check status of mail – Biki Maharjan Jan 12 '21 at 05:03
1 Answers
0
In the docs there are methods to see if an email has bounced:
Getting Error Reports from an Email:
@mail = Mail.read('/path/to/bounce_message.eml')
@mail.bounced? #=> true
@mail.final_recipient #=> rfc822;mikel@dont.exist.com
@mail.action #=> failed
@mail.error_status #=> 5.5.0
@mail.diagnostic_code #=> smtp;550 Requested action not taken: mailbox unavailable
@mail.retryable? #=> false
So when you send it you can run puts @mail.bounced?
if you have access to the instance variable of the mail sent, otherwise find where the .eml
message is saving.

Kelsey Hannan
- 2,857
- 2
- 30
- 46