Continue to receive the sender (Return-Path, Sender, or From) required to send the message

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 set my default value: from, so I don’t understand why I keep receiving this message, I also try 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 that, SupportMailer.support_response(@message).deliver

How to fix it?

+6
source share
1 answer

I notice that you do not have a default case for the case statement. If you never call the mail method inside your methods in the Mailer class, you will get this error. Try moving your case argument to where you call SupportMailer, there may be methods for each case. This way, you never call SupportMailer unless you have already determined the correct game with tickets.

+3
source

Source: https://habr.com/ru/post/910627/


All Articles