Closed tomgallagher closed 7 years ago
Hello @tomgallagher
I have tried the gmail
gem on IRB as well as I use it in rake task
to send mails and it works as expected, can you provide more detail for this, I'm not able to reproduce this.
Example:
task :test => :environment do
gmail = Gmail.new('username', 'password')
gmail.deliver do
to "test@gmail.com"
subject "attached image and link"
body "test gmail mails https://github.com/gmailgem/gmail"
end
end
try rake test
This sends mail successfully.
Thanks .
Hi
This was a problem with my development environment being a cloud IDE.
The Cloud IDE (hosted on Google's Compute Engine platform) was blocking SMTP access to any of the normal ports.
No-one has been able to explain to me why it would block the rake task but not the IRB.
If anyone comes across this later, my advice is to forget about SMTP and try to use one of the mail providers REST API interfaces (Mailgun, SendGrid). That may not work for everyone but it's where I ended up.
Thanks for your attention, anyway.
Hi
I'm a bit stumped.
I am using the gmail gem. Tested in IRB and all running as expected. Connect to Gmail, send message, message received.
Yet when I try exactly the same code in a rake task, I get the following error after I have successfully logged on:
rake aborted! OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=unknown state: unknown protocol /usr/local/rvm/gems/ruby-2.2.1/gems/mail-2.6.3/lib/mail/network/delivery_methods/smtp.rb:112:in 'deliver!' /usr/local/rvm/gems/ruby-2.2.1/gems/mail-2.6.3/lib/mail/message.rb:2141:in 'do_delivery' /usr/local/rvm/gems/ruby-2.2.1/gems/mail-2.6.3/lib/mail/message.rb:238:in 'deliver' /home/ubuntu/workspace/lib/tasks/proxy_manager.rake:13:in 'block in <top (required)>'
I've had a look at the line where the problem occurs in the mail gem.
It looks like I need to specify an SMTP authentication method but I do not know how to do that in gmail gem.
Any help appreciated.
Tom