class SupportMailer < ActionMailer::Base
default :from => "email1@gmail.com"
def welcome_email(ticket)
case ticket.game
when "gameone"
@ticket = ticket
headers["Reply-to"] = "email1+#{ticket.token}@gmail.com"
headers["Return-Path"] = "email1+#{ticket.token}@gmail.com"
mail(:from => "email1@gmail.com", :to => ticket.email, :subject => "Welcome to 1 Support Ticket")
when "gametwo"
@ticket = ticket
headers["Reply-to"] = "email2+#{ticket.token}@gmail.com"
headers["Return-Path"] = "email2+#{ticket.token}@gmail.com"
mail(:from => "email2@gmail.com", :to => ticket.email, :subject => "Welcome to 2 Support Ticket")
when "gamethree"
@ticket = ticket
headers["Reply-to"] = "email3+#{ticket.token}@gmail.com"
header["Return-Path"] = "email3+#{ticket.token}@gmail.com"
mail(:from => "email3@gmail.com", :to => ticket.email, :subject => "Welcome to 3 Support Ticket")
end
end
end
I've set my default :from, so I don't get why I keep getting this message, I'm also trying to set it via headers to no avail.
here are my settings
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:user_name => "emailx@gmail.com",
:password => "password",
:authentication => "plain",
:enable_starttls_auto => true
}
I just call it like so, SupportMailer.support_response(@message).deliver
How do I fix this?
I notice you have no default case for the case statement. If you never end up calling the "mail" method inside your methods in the Mailer class, you'll get that error. Try moving your case statement out to where you call SupportMailer, maybe have methods for each case. That way you never call the SupportMailer unless you've already determined the correct ticket game.