0

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.

Eyeslandic
  • 14,553
  • 13
  • 41
  • 54
Biki Maharjan
  • 388
  • 3
  • 10

1 Answers1

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