Mail sending issue using dreamhost with ruby on rails - ruby-on-rails

I'm trying to send mail using using dreamhost credential with ruby on rails.
My development.rb file mail setting as following.
config.action_mailer.smtp_settings = {
address: "dreamhost.com",
port: 587,
domain: "www.dreamhost.com",
authentication: "plain",
enable_starttls_auto: true,
user_name: ENV['mailer'],
password: ENV['mailer_password']
}
Mail is not able to send using above mail configuration I'm getting error like Errno::ECONNREFUSED (Connection refused for "dreamhost.com" port 587).
Can any one help me for this issue?

This is my profile I use on Dreamhost
config.action_mailer.perform_caching = false
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
config.action_mailer.raise_delivery_errors = false
config.action_mailer.delivery_method = :smtp
config.action_mailer.default_options = {from: 'notifications#mywebsite.org'}
config.action_mailer.smtp_settings = {
address: 'sub5.mail.dreamhost.com',
port: 587,
domain: 'mywebsite.org',
user_name: 'notifications#mywebsite.org',
password: 'mypassword',
authentication: :login,
enable_starttls_auto: false }
Note that sub5.mail.dreamhost.com is domain-dependent address of your datacenter server.
NB: Password should be hidden into ENV variables or other external file outside version control

Related

Rails not sending mails in development via Mandrillapp (nodename nor servname provided)

I'm running into this issue:
SocketError in Front::RequestsController#create
getaddrinfo: nodename nor servname provided, or not known
Extracted source (around line #539):
#537
#538 def tcp_socket(address, port)
*539 TCPSocket.open address, port
#540 end
#541
#542 def do_start(helo_domain, user, secret, authtype)
When trying to send mails via Mandrillapp locally. This is my development.rb file:
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp
# Specify what domain to use for mailer URLs
config.action_mailer.smtp_settings = {
user_name: 'my_user_name',
password: 'my_password',
domain: 'localhost:3000',
address: 'smtp.mandrillapp.com"',
port: 587,
authentication: :plain,
enable_starttls_auto: true
}
On production everything works fine, even when loading those variables via Figaro (application.yml). However, on development mode, I'm running into the issue provided above.
I tried different ports, different settings... Nothing works on development. Could someone point me, at least, into the right debugging direction? Most SO-answers, like this doesn't help at all.
As per the details shared it seems there you have added an extra quote in address key when specifying smtp settings and when trying to connect to address it is showing this error:
Current Setting
config.action_mailer.smtp_settings = {
user_name: 'my_user_name',
password: 'my_password',
domain: 'localhost:3000',
address: 'smtp.mandrillapp.com"',
port: 587,
authentication: :plain,
enable_starttls_auto: true
}
Update Setting:
config.action_mailer.smtp_settings = {
user_name: 'my_user_name',
password: 'my_password',
domain: 'localhost:3000',
address: 'smtp.mandrillapp.com',
port: 587,
authentication: :plain,
enable_starttls_auto: true
}

ActionMailer not sending mail in development Rails 5

I am having some problem with sending email in my web-application. When I am running development the email is not sent even though it is showing as sent in the Console.
This is my settings in config/environments/development.rb
# Email
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: '587',
enable_starttls_auto: true,
user_name: ENV["gmail_username"],
password: ENV["gmail_password"],
authentication: :plain,
domain: 'gmail.com'
}
In my controller I am sending mail using this call:
JobMailer.send_accept_job_mail(#app_user, #job.id).deliver
The mail is showing as "sent" in the Console, but it is not sent to the specified mail.
You need to use deliver! to send out the mail immediately.
Just update the code to
JobMailer.send_accept_job_mail(#app_user, #job.id).deliver!
-- edited to use deliver! method, per comments.

Mandrill invalid key error

I have a problem with an app developing on cloud9. I'm using mandrill to send email but it gives me a problem with configuration. It seems to be an invalid key error but in local development it works with the same configuration...
There are my smtp in development environment:
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.default_url_options = { host: config.app_domain }
config.action_mailer.smtp_settings = {
address: 'smtp.mandrillapp.com',
port: '587',
enable_starttls_auto: true,
user_name: ENV['mandrill_username'],
password: ENV['mandrill_password'],
authentication: :plain,
domain: ENV['mandrill_domain']
}
Thanks for help.
Since Cloud9 workspaces are hosted on GCE servers, there are restrictions in place for sending email from a GCE instance. The following article explains the restrictions:
https://cloud.google.com/compute/docs/tutorials/sending-mail/

Rails ActionMailer Send Email Without Authentication

So, one of my projects has a SMTP server that has been configured to be used without any form of authentication. Here is my SMTP setting on config/environments/production.rb.
config.action_mailer.asset_host = 'http://example.com'
config.action_mailer.default_url_options = { host: 'example.com' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.raise_delivery_errors = true
config.action_mailer.smtp_settings = {
address: 'mail.example.com',
port: 587,
domain: 'info.example.com',
user_name: 'no-reply#example.com',
password: '',
openssl_verify_mode: 'none',
authentication: nil,
tls: false,
enable_starttls_auto: false
}
I though the authentication mode needs to be set to nil but, when I tried to send email, it gave me this error.
2.0.0-p481 :001 > CustomerMailer.test.deliver
Net::SMTPAuthenticationError: 503 5.5.1 Error: authentication not enabled
Any solution, guys?
You're specifying authentication details. ActionMailer will accordingly use them.
Solution: Don't.
config.action_mailer.smtp_settings = {
address: 'mail.example.com',
port: 587,
domain: 'info.example.com'
}
(The domain parameter may itself be unnecessary depending on your server configuration.)

How to send emails in development environment using gmail SMTP and devise?

I am trying to send emails while being on localhost and using devise (I need emails for user registration and password reset)
I have put this in my environment.rb file
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: "gmail.com",
authentication: "plain",
enable_starttls_auto: true,
user_name: ENV["username"],
password: ENV["password"]
}
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
but I am not getting any mails and not seeing any error too (devise says ).
What am I missing ?
Where can I see the log for emails (success or
failure) ?
EDIT - OK, it worked after adding this line
:openssl_verify_mode => 'none'
Check this too rails email error - 530-5.5.1 Authentication Required.

Resources