ishwr
ishwr

Reputation: 745

ActionMailer Rails 3

this is my first time using ActionMailer. I have a hard time set the sender email. This is my development.rb :

config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    address:              'smtp.gmail.com',
    port:                 587,
    user_name:            'foo',
    password:             'mypass',
    authentication:       'plain',
    enable_starttls_auto: true  
}
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true

And this is my feedback_mailer.rb :

class FeedbackMailer < ActionMailer::Base
  def feedback_email(feedback, setting_configuration)
    @feedback = feedback
    @setting_configuration = setting_configuration
    mail(to: @setting_configuration.value, :from => feedback.email, subject: @feedback.inquiry_type )
  end
end

But the sender email is still [email protected]. Can I set the sender's email using smtp? Or I have to use sendmail? I tried using :sendmail, instead of smtp, but I have this error :

Errno::ENOENT - No such file or directory - /usr/sbin/sendmail -i -t -f 

What should I set in the sendmail? I tried googled it and everything, but nothing worked. Would be really glad, if anyone could help. Thanks

Upvotes: 0

Views: 219

Answers (1)

Michael Venable
Michael Venable

Reputation: 5051

What you have looks correct. The "from" argument in the call to mail should set the email address that is on the email. We're using Sendgrid on Heroku and it works. This makes me suspect that maybe Google is replacing it with the account holder's email address. Perhaps test it using another email service and see if you have better luck.

Upvotes: 1

Related Questions