11155
(-- --)
February 14, 2012, 3:32pm
1
Hey all, well I am trying to send emails to newly created users but I
have a problem.
In the rails log it states that the email has been sent but the email is
never actually received so obviously there is a problem.
I have noticed one in particular and I don't understand how to fix it.
Once I create the user I get the following error message:
Net::SMTPAuthenticationError (535-5.7.1 Username and Password not
accepted.
How do I set a username and password?
I have the following in my development.rb:
config.action_mailer.raise_delivery_errors = false
# config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtphost.aber.ac.uk",
:port => 25,
:domain => "Christopher-PC"
}
ADMIN_EMAIL="chris230391@aol.com"
Any help would be much appreciated. Thanks.
ActionMailer::Base.smtp_settings = {
:address => “address”,
:port => “port”,
:user_name => “email”,
:password => “password”,
:authentication => “plain”,
:enable_starttls_auto => true
}
I use this settings… maybe it can help, but it’s in an initializers file
Javier Q.
11155
(-- --)
February 14, 2012, 4:44pm
3
ActionMailer::Base.smtp_settings = {
:address => "address",
:port => "port",
:user_name => "email",
:password => "password",
:authentication => "plain",
:enable_starttls_auto => true
Hey Javier, I added the above settings to my development.rb and I no
longer get the username and password error, it allows me to create the
new user no problems at all which is great except one major problem,
despite the log stating that the email has been sent I have received
nothing
Any ideas?
Have you considered using Devise gem? it has that option (sending emails every time a user is created). I’m not using it now.
Inside my app folder I have a mailers folder an inside a user_mailer.rb
class UserMailer < ActionMailer::Base
default from: “Name ”
def sender_method_name_here( user , something_else)
@user = user
@data = “something_else”
mail :to => @user.email, :subject => "subject"
end
end
but this is even easier with devise (I don’t remember well but you can see the documentation of it in github
Javier Q.
11155
(-- --)
February 14, 2012, 7:18pm
5
I have the following in my user_mailer.rb similar to you but it doesn't
seem to work for me:
class UserMailer < ActionMailer::Base
default :from => "notifications@example.com"
def registration_confirmation(user)
@user = user
@url = "http://localhost:3000 "
mail(:to => user.email,:subject => "Welcome")
end
end
Pretty much stumped at this point because everything I have is by the
book so why doesn't it work.
This is what I used..
100% working..
@full_message = <<MESSAGE_END
This is a sample message
MESSAGE_END
@sent=0
smtp = Net::SMTP.new('smtp.gmail.com', 25)
smtp.enable_starttls
smtp.start('mail.google.com',username, password, :login) do |smtp|
if @sent==0
smtp.send_message @full_message , 'from-address@example.com',
['to@email.com']
@sent=1
end
end
hope this helped you..
No gem require
11155
(-- --)
February 17, 2012, 1:41pm
7
@full_message = <<MESSAGE_END
To: to@gmail.com
Subject: its working!
This is a sample message
MESSAGE_END
So the above is your text.rb message?
@sent=0
smtp = Net::SMTP.new('smtp.gmail.com', 25)
smtp.enable_starttls
smtp.start('mail.google.com',username, password, :login) do |smtp|
if @sent==0
smtp.send_message @full_message , 'from-address@example.com',
['to@email.com']
@sent=1
end
end
The above code, where is this stored? is it in the development.rb? is
this all it is or is it incased in a method?
Appreciate the help. Thanks.