I am trying to set up an action mailer, so people can send a message using contact form on my website.
Here is my configuration for production:
config.action_mailer.default_url_options = { host: 'mydomain.co' }
config.action_mailer.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => 'smtp.gmail.com',
:port => 587,
:authentication => :plain,
:user_name => ENV['GMAIL_USERNAME'],
:password => ENV['GMAIL_PASSWORD'],
:domain => 'mydomain.co',
:enable_starttls_auto => true
}
I was trying to test it and the mail is delivered, but after that I immidiately receive a message from "Mail Delivery Subsystem" with a subject "Delivery Status Notification (Failure)".
What is causing this message and how to avoid it?
Mine looks like this
config.action_mailer.smtp_settings = {
:address => 'smtp.gmail.com',
:port => 587,
:domain => 'gmail.com',
:user_name => ENV["GMAIL_USERNAME"],
:password => ENV["GMAIL_PASS"],
:authentication => 'plain',
:enable_starttls_auto => true
}
Also make sure you've enabled "Less Secure Apps" in your Gmail settings:
https://support.google.com/accounts/answer/6010255?hl=en
Hope that helps!
Related
I am migrating an ROR3 application to ROR4. And I am very new to this and I am learning along with the migration.
I got stuck in the first step it self
I am getting an error
Net::SMTPAuthenticationError in ClientsController#create
534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbtq6
Here is my configuration in development.rb.
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:user_name => Rails.application.secrets.email_address,
:password => Rails.application.secrets.email_password,
:authentication => "plain",
:enable_starttls_auto => true }
The place where I am getting the error is at
#client.save.
Apartment::Tenant.create(#client.subdomain)
Apartment::Tenant.switch(#client.subdomain)
#client.save
redirect_to new_user_session_url(subdomain: #client.subdomain)
else
render action: 'new'
Can anyone help who is working on ROR?
I had this same issue, be sure to take a look at your gmail account security settings and enable "Access for less secure apps" from www.google.com/settings/security."
Try this
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:user_name => "your mail",
:password => "your password",
:authentication => :plain,
:enable_starttls_auto => true
}
I am deploying an ruby-on-rails app in Heroku.I cannot add the SendGrid add-on to the heroku account.Is there any other ways to use the email services?
Yes you can simply sign up for a SendGrid account directly and then use the SMTP details. It would look like this:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.sendgrid.net",
:port => 587,
:domain => 'yourdomain.com',
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:authentication => 'plain',
:enable_starttls_auto => true
}
There's also an example using the Mail gem, in the SendGrid documentation.
You could use your Gmail account.
In config > environment > production.rb
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => 'gmail.com',
:user_name => ENV['GMAIL_USER_NAME'],
:password => ENV['GMAIL_PASSWORD'],
:authentication => 'plain',
:enable_starttls_auto => true
}
Then you have to set GMAIL_USER_NAME and GMAIL_PASSWORD to Heroku configs
GMAIL_USER_NAME should be your email address of gmail domain eg. sample#gmail.com
I'd like to create contact form using this tutorial
At the end of that is writen that I should configure SMTP, so in config/environments/developement.rb I set
config.action_mailer.default_url_options = {:host => 'myproject.c9.io'}
(I'm using rails on c9.io)
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:user_name => "myusername",
:password => "mypassword",
:authentication => "plain",
:enable_starttls_auto => true
}
I'm fairly new in rails and especially in sending emails, so I'd like to ask, because I don't get message on my email address when I fill form and send, what should I do to get a confirmation of correct sending. I know that there is a lot of tutorials on the Internet but now I'm in the muddle, so I'll be grateful for explanation.
Add these config to your development.rb reference
config.action_mailer.default_url_options = {:host => 'myproject.c9.io'}
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: 'gmail.com',
user_name: 'myusername',
password: 'mypassword',
authentication: 'plain',
enable_starttls_auto: true
}
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => ???,
:user_name => ???,
:password => ???,
:authentication => "plain",
:enable_starttls_auto => true
}
I'm trying to use Action Mailer in Rails to send email to users. I don't quite understand what should go into :domain, :user_name, and :password. Should it be gmail.com, my Gmail username, and my Gmail password?
Here is an example of setting up ActionMailer to use GMAil to send mail:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => 'gmail.com',
:user_name => 'my_user_name#gmail.com',
:password => 'my_gmail_password',
:authentication => 'plain',
:enable_start_tts_auto => true
}
The domain should be "gmail.com" and the username and password should be those of your Google account. To better protect your main GMail account, you should setup a separate GMail account just for sending email.
I don't think you need to specify domain, but yes, the user name and password must be the corresponding username/password for the sender email
I tried to configure actionmailer to send via google apps with smtp.
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "mydomain.com",
:user_name => "username",
:password => "password",
:authentication => 'plain',
:enable_starttls_auto => true }
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
However whenever gitlab tries to send an e-mail:
Sent mail to user#my.domain.com (10ms)
Completed 500 Internal Server Error in 29ms
535-5.7.1 Username and Password not accepted
Server runs ruby 1.9.3p194. Why doesn't google apps accept the username/password?
It works now, I think the problem was with the username. it needs the domain in the username. i.e. the problem was
user_name: 'username'
Whereas the correct way (at least for google apps) is
user_name : 'username#mydomain.com'
this works for me:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:user_name => "you#gmail.com",
:password => "password",
:authentication => 'plain',
:enable_starttls_auto => true }
Try setting the domain to gmail.com