I'm trying to send emails but the emails will never use my :from =>
code, instead the email always arrives using the 'from' of my gmail smtp settings. So for example the email arrives and says FROM: [email protected] instead of FROM: [email protected] , and in the logs it shows the email sent using the FROM: [email protected] which is from my devise initializer.
How can I fix this? Its really upsetting at the moment :( Thanks for any help.
I'm using Gmail and setup my smtp settings like this:
config/initializers/mailer_setup
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "mydomain.com",
:user_name => "[email protected]",
:password => "mypassword",
:authentication => "plain",
:enable_starttls_auto => true
}
mailer/user_mailer.rb
def reset_password_instructions(user)
@user = user
@url = "http://localhost:3000"
mail(:to => user.email,
:from => "[email protected]",
:subject => "recover your password"
)
end
end
Log
Started GET "/users/password/new" for 127.0.0.1 at 2011-12-04 12:03:22 -0700
Processing by Devise::PasswordsController#new as HTML
Rendered devise/shared/_links.erb (1.7ms)
Rendered devise/passwords/new.html.erb within layouts/application (2103.3ms)
Completed 200 OK in 2122ms (Views: 2112.1ms | ActiveRecord: 0.8ms)
Started POST "/users/password" for 127.0.0.1 at 2011-12-04 12:03:27 -0700
Processing by Devise::PasswordsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"hEYh1/G9P0noE+VobBbgremT+rpt+fJFez7H99dOGNM=", "user"=>{"email"=>"[email protected]"}, "commit"=>"Send me reset password instructions"}
User Load (1.7ms) SELECT "users".* FROM "users" WHERE "users"."email" = '[email protected]' LIMIT 1
Rendered devise/mailer/reset_password_instructions.html.erb (1.0ms)
Sent mail to [email protected] (3585ms)
Date: Sun, 04 Dec 2011 12:03:28 -0700
From: [email protected]
Reply-To: [email protected]
To: [email protected]
Message-ID: <[email protected]>
Subject: Reset password instructions
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
<p>Hello [email protected]!</p>
<p>Someone has requested a link to change your password, and you can do this through the link below.</p>
<p><a href="http://localhost:3000/users/password/edit?reset_password_token=Gg3Aqe6sFD3rDLUAda47">Change my password</a></p>
<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>
Redirected to http://localhost:3000/users/sign_in
Completed 302 Found in 4281ms
Started GET "/users/sign_in" for 127.0.0.1 at 2011-12-04 12:03:32 -0700
Processing by Devise::SessionsController#new as HTML
Rendered devise/shared/_links.erb (1.7ms)
Rendered devise/sessions/new.html.erb within layouts/application (80.7ms)
Completed 200 OK in 340ms (Views: 90.6ms | ActiveRecord: 2.3ms)