Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keep getting A sender (Return-Path, Sender or From) required to send a message

class SupportMailer < ActionMailer::Base
  default :from => "[email protected]"

  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 => "[email protected]", :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 => "[email protected]", :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 => "[email protected]", :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            => "[email protected]",
  :password             => "password",
  :authentication       => "plain",
  :enable_starttls_auto => true
}

I just call it like so, SupportMailer.support_response(@message).deliver

How do I fix this?

like image 924
Joseph Le Brech Avatar asked Mar 13 '12 19:03

Joseph Le Brech


People also ask

Is return path the same as sender?

The return-path header (return-path header, in English) is an SMTP email source address (SMTP MAIL FROM, in English) used to process the bounces that occur in your emails. It can also be called reverse path, sender, sender, MAIL DE, 5321-DE, sender, De_ and Errors a. This address receives information on all bounces.

What is an email return path?

The return-path is used to process bounces from your emails and is set in the email header. It defines how and where bounced emails will be processed. The return-path can also be referred to as a bounce address or a reverse path, and is an SMTP address that is separate from your sending address.

How do I change my return path?

Changing the Return-Path Header on Your Training EmailsClick your email address on the top-right of the screen, then click Account Settings. Navigate to the Training Settings section. Under the Training Email Headers subsection, click the checkbox next to Overwrite Fixed Return-path Address with Sender Address.

Can email return path be spoofed?

RETURN-PATH This can also be spoofed, but a lazy scammer will leave the actual RETURN-PATH address. If you see a different sending address here, the email may have been spoofed.


1 Answers

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.

like image 80
davekaro Avatar answered Oct 16 '22 17:10

davekaro