Abort sending an email in ActionMailer, Rails 3
Recently I’ve seen some issues popping up in production. Emails aren’t being sent, raising this damn error :
ArgumentError: A sender (Return-Path, Sender or From) required to send a message
After banging my head against the wall for a while, I realized some old code I had put in place to handle this was either out of date, or never correct to begin with. I saw someone have this issue on Stack Overflow recently and dropped the solution there: http://stackoverflow.com/questions/4452149/rails-3-abandon-sending-mail-within-actionmailer-action
Trick is just to do a self.message.perform_deliveries = false inside the mailer method you want to stop.
This is current for Rails 3.2.3