ActionMailer emails "sent" in development.log, but not received - ruby-on-rails

I'm having problems actually sending via ActionMailer in development, on my localhost, with Rails 2.3.2 and Ruby 1.8.6. The development.log shows that it has "sent" the email with no errors, but the email is not received. I have tried multiple email addresses for sending and receiving and have tried multiple configs and plugins, but cannot get the email to send. Any help would be much appreciated - I feel like I'm dancing around a bunch of versions of solutions for different versions of rails and ruby and can't nail it down. I would much appreciate any comments. Thanks!
Plugins:
action mailer optional tls
smtp_tls
Different email configs:
ActionMailer::Base.smtp_settings = {
:enable_starttls_auto => true, #works in ruby 1.8.7 and above
:address => 'smtp.gmail.com',
:port => 587,
:domain => 'example.com',
:authentication => :plain,
:user_name => 'testacct',
:password => 'secret'
}
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:tls => :true,
:address => 'smtp.gmail.com',
:port => 587,
:authentication => :plain,
:user_name => 'testacct#gmail.com',
:password => 'secret'
#:enable_starttls_auto => true # for rails >= 2.2 && ruby >= 1.8.7
}
config.action_mailer.perform_deliveries = :true #try to force sending in development
config.action_mailer.raise_delivery_errors = :true
config.action_mailer.default_charset = "utf-8"
Development.log:
Sent mail to sa23kdj#trash2009.com
Date: Fri, 18 Dec 2009 00:27:06 -0800
From: Test Email Acct <testacct#gmail.com>
To: sa23kdj#trash2009.com
Subject: Signup
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=mimepart_4b2b3cda9088_634334302a5b7
--mimepart_4b2b3cda9088_634334302a5b7
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ww=
w.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang=3D'en' xml:lang=3D'en' xmlns=3D'http://www.w3.org/1999/xhtml'>=
<head>
<meta content=3D'text/html;charset=3DUTF-8' http-equiv=3D'content-typ=
e' />
</head>
<body>
Welcome Email
<p>
user name:
lfglkdfgklsdf
activation link:
http://localhost:3000/login
</p>
</body>
</html>
--mimepart_4b2b3cda9088_634334302a5b7--

Put the following in config/environments/development.rb
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
It will override the settings in config/environment.rb
Also for rails 2.X you'll need to setup:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:enable_starttls_auto => true,
:address => "smtp.gmail.com",
:port => 587,
:domain => "domain.com",
:user_name => "username#domain.com",
:password => "secret_passsword",
:authentication => :plain
}

You need to use true and not :true.
:tls => true
...
config.action_mailer.perform_deliveries = true #try to force sending in development
config.action_mailer.raise_delivery_errors = true

In case anyone faces this problem, set "config.action_mailer.raise_delivery_errors = true" in development.rb in your environments folder and try sending mail again. This should raise whatever error is being encountered.
Sometimes in line 8 of smtp_tls.rb , the check_auth_args method accepts only 2 arguments : user and secret. Remove the 'authtype' argument if you see it and try again. Should work.

Related

Rails w/devise authentication what is the configuration of iRedMail?

We're using successfully iRedMail in 4 email servers (8 domains) for our own email accounts.
We develop web apps based on RoR. We would like to know what is the iRedMail configuration for sending to users, via rails and devise gem, https://github.com/plataformatec/devise, the password reminds, emails confirmations, etc.. What is the difference between address and domain? How to test?
After Googling and posting in iRedMail forum unsuccessful, we only find smt gmail config, please find below.
Thanks in advance!
==== DEVISE config/environments/development.rb ====
SMTP GMAIL CONFIG:
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "mail.google.com",
:user_name => "my#gmail.com",
:password => "mypassword",
:authentication => :plain,
:enable_starttls_auto => true
}
==== BACK-END ====
iRedMail 0.9.7 MARIADB edition.
Debian GNU/Linux 9 (stretch) in a fresh OVZ-6GB
Mysql/MariaDB w/adminer
Apache/2.4.25 (Debian)
PHP 7.0.19-1
Ruby 2.5.0, Rails 5.1.5 and Phusion Passenger 5.2.1
No errors: /var/log/iredapd/iredapd.log
=============================
Editing DEVISE config/environments/development.rb
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.smtp_settings = {
:address => "mx.coopeu.com",
:port => 587,
:domain => "mx.cooopeu.com",
:user_name => "coopeu#coopeu.com",
:password => "password",
:authentication => :plain,
:enable_starttls_auto => true
}
Also raising error:
Net::SMTPFatalError in ConfirmationsController#create
554 5.7.1 : Recipient address rejected: Sender is not same as SMTP authenticate username
It means you use user "coopeu#coopeu.com" for SMTP authentication, but specify user "someone-else#somedomain.com" as the sender address.
If you need to allow the sender address mismatch for this smtp user, you can add one setting in
/opt/iredapd/settings.py
to allow it, like below:
ALLOWED_LOGIN_MISMATCH_SENDERS = ['coopeu#coopeu.com']
Restarting iredapd after modified "settings.py".
and it's working right

Action Mailer Not delivering Emails - MailCatcher and sendmail

I am using Rails 5. I have the following configurations in my config/environments/development.rb and config/environments/staging.rb.
config/environments/development.rb
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = { address: "localhost", port: 1025 }
When I call the method that sends email, I get the following output.
Rendering mailer/consolidated_s3_storage_report.html.erb
Rendered mailer/consolidated_s3_storage_report.html.erb (0.4ms)
Mailer#consolidated_s3_storage_report: processed outbound mail in 17668.1ms
=> #<Mail::Message:86763960, Multipart: true, Headers: <From: mcds#sheridan.com>, <To: mcds.support#sheridan.com>, <Subject: 2017 July - S3 Storage Report>, <Mime-Version: 1.0>, <Content-Type: multipart/mixed; boundary="--==_mimepart_595c962cc36fb_1be1b2198436941"; charset=UTF-8>>
But email is not delivered to my gmail. The 'from' address is 'default from' from which all other emails are sent. Please clarify why my emails are not delivered.
You seem to be using Mailcatcher. Mailcatcher doesn't deliver messages, its to prevent messages from delivering to the actual To email addresses but lets you check of the message is framed correctly. Developers use Mailcatcher in development enviroments to see if the emails are rendered as they expect them to look like without spamming the To email holder.
All the emails that are sent to Mailcatcher can be viewed in a web interface. Visit http://localhost:1080 on your computer, you should be able to see all the emails you send so far from the development environment.
Following is the configuration for send mail to gmail:
config/environments/development.rb
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:user_name => "user#gmail.com", #your gmail id
:password => "password", #your gmail password
:authentication => "plain",
:enable_starttls_auto => true
}

Completed 500 Internal Server Error in Rails 4 Devise Signup process

When I go to signup a new user on the site I fill in the form, click submit, and it sits there for a few seconds, then dispays 'We're sorry, but something went wrong.'
The Log is below...
https://gist.github.com/th3cuda/225f1352a7cfeee3f8f8
This is deployed on digitalocean.
production.rb
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
config.action_mailer.default_url_options = { :host => 'MY_HOST' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => 'smtp.MY_DOMAIN.com',
:port => 465,
:domain => 'MY_DOMAIN',
:user_name => 'MY_EMAIL',
:password => 'PASSWORD',
:authentication => 'plain',
:enable_starttls_auto => true
}
end
Since it's taking a while, it could be looking for sendmail (it uses /usr/sbin/sendmail by default) to send the email.
I would make sure that it's in place, that it can be used by the app, and that the config/(Dev, Prod, etc.) allows it to deliver email.
Is any of that helpful? Let me know what you find so I can give a better answer.
Sorry to add another answer, but formatting here is important.
config.action_mailer.default_url_options = { :host => 'MY_HOST' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => 'smtpout.secureserver.net',
:port => 80,
:domain => 'www.example.com',
:user_name => 'johndoe#example.com',
:password => 'yourpassword',
:authentication => 'plain'
}
end
Notice I removed the starttls option, and set port to 80. Obviously, replace with your real values. If you're using constants, please avoid using those until this gets resolved.

emails not sending in ruby on rails

I did the same thing as in this link http://www.tutorialspoint.com/ruby-on-rails/rails-send-email.htm. it is showing mail sent in output window of net-beans with the message but it is not actually sending the mail. can anyone tell me what could be the problem?
i have searched a lot but m not getting any solution.
I am using net-beans with ruby 1.5.1, rails 2.3.8. I have searched but I only got the solution to update j-ruby. If it is so then please tell me how to use updated version of j-ruby in net-beans.
the following code is in environment.rb
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => 'gmail',
:user_name => "id#gmail.com",
:password => "",
:authentication => 'plain',
:enable_starttls_auto => true }
thanks
can you please check that whether you have do this or not
config.action_mailer.perform_deliveries = true
Please let me know
Thanks
Please check with your network provider if your smtp port is open. or check using telnet commands. If you work under a company network which has restrictions on sending mails, you should explicitly ask for permission and get the port opened.
The mail sent message will be shown in output even if it isnt actually sent. So pls make sure you have the following changes made to know the errors in your config/environments/development.rb or production.rb depending on in which mode you are running your server
config.action_mailer.raise_delivery_errors = true
Visit the following link for more detail about Action Mailer.
Update your mailer settings:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => 'gmail',
:user_name => "id#gmail.com",
:password => "******",
:authentication => 'plain',
:enable_starttls_auto => true }
Where ****** is your email password.

Rails ActionMailer configuration for Zoho

Anyone have luck configuring ActionMailer to send email via a Zoho account?
These are my settings:
ActionMailer::Base.smtp_settings = {
:address => "smtp.zoho.com",
:port => 465,
:domain => 'example.com',
:user_name => 'steve#example.com',
:password => 'n0tmypa$$w0rd',
:authentication => :login
}
However, calling .deliver times out:
irb(main):001:0> AdminMailer.signup_notification('asfd').deliver
Timeout::Error: Timeout::Error
from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:146:in `rescue in rbuf_fill'
from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:140:in `rbuf_fill'
from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:122:in `readuntil'
from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:132:in `readline'
from C:/Ruby193/lib/ruby/1.9.1/net/smtp.rb:929:in `recv_response'
from C:/Ruby193/lib/ruby/1.9.1/net/smtp.rb:552:in `block in do_start'
from C:/Ruby193/lib/ruby/1.9.1/net/smtp.rb:939:in `critical'
from C:/Ruby193/lib/ruby/1.9.1/net/smtp.rb:552:in `do_start'
from C:/Ruby193/lib/ruby/1.9.1/net/smtp.rb:519:in `start'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/mail-2.4.4/lib/mail/network/delivery_methods/smtp.rb:144:in `deliver!'
The help docs say to use port 465 and SSL authentication. I've tried with and without :enable_starttls_auto => true but it still times out.
Specifically, the docs specify the following settings:
> Email Address: Username#yourdomain.com
> User Name format: Username#yourdomain.com
> Secure Connection (SSL) Yes
> Outgoing Mail Server Name: smtp.zoho.com
> Outgoing Port No.: 465
> Outgoing Mail Server requires authentication: Yes
Any ideas?
p.s. I've configured Outlook to use the settings in the help docs and outgoing email works fine. telnet to smtp.zoho.com 465 also connects.
# Action Mailer
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "smtp.zoho.com",
:port => 465,
:user_name => 'someone#somewhere.com',
:password => 'password',
:authentication => :login,
:ssl => true,
:tls => true,
:enable_starttls_auto => true
}
That worked for me. Your settings might be fine some local networks block these kinds of packets. I had to test it through my 3G network.
FYI:
Let's say your domain is abc.com.
Let's say you have 'default from' on your mailer with a different domain, e.g.
default from: "\"Elephant\" <el#ephant.com>"
This will not work unless you change your 'default from' using the same domain on your zoho account.
So,
default from: "\"Elephant\" <el#abc.com>"
will work.
I'm not sure if Zoho have changed their security settings, but #Tyrel Richey's accepted answer didn't work for me. However, the following does:
/config/initializers/action_mailer.rb..
# ActionMailer email configuration
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => ENV['SMTP_ADDRESS'],
:port => ENV['SMTP_PORT'],
:domain => ENV['SMTP_DOMAIN'],
:user_name => ENV['SMTP_USERNAME'],
:password => ENV['SMTP_PASSWORD'],
:authentication => :login,
:enable_starttls_auto => true
}
Where..
:address = smtp.zoho.com
:port = 587
:domain is localhost in development, and the live URL in production (e.g. example.com)
I have mail sending with Rails 4.2.3 like so...
# config/environments/development.rb
Rails.application.configure do
#...
config.action_mailer.default_url_options = { host: 'domain' }
config.action_mailer.smtp_settings = { address: 'smtp.zoho.com', port: 465, user_name: 'username#domain.com', password: 'mypassword', authentication: :login, ssl: true }
end
You can of course use this in production as well by adding this to config/environments/production.rb
I also set the email address in config/initializers/devise.rb so I can send password reset instruction.
config.mailer_sender = 'noreply#truhawk.com'
References
https://www.zoho.com/mail/help/zoho-smtp.html
http://guides.rubyonrails.org/action_mailer_basics.html
These settings worked for me in production.
Rails.application.routes.default_url_options[:host] = 'eyehawk.io'
config.action_mailer.default_url_options = { :host => 'eyehawk.io' }
config.action_mailer.perform_caching = false
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"
config.action_mailer.smtp_settings = {
:address => "smtp.zoho.com",
:port => 587,
:domain => "zoho.com",
:user_name => "admin#eyehawk.io",
:password => ENV['SMTP_PASSWORD'],
:authentication => :plain,
:enable_starttls_auto => true
}
Using smtp.zoho.eu instead of smtp.zoho.com as address did the trick for me.

Resources