Created
January 27, 2017 22:23
-
-
Save becomingwisest/983d2e71770df889579d1b6544fc6f19 to your computer and use it in GitHub Desktop.
ruby mail gem ssl issues
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ChristopherEvans:2.1.10-alpine christopher.evans$ docker build -t 2.1.10-alpine . | |
Sending build context to Docker daemon 4.608 kB | |
Step 1 : FROM ruby:2.1.10-alpine | |
---> 5ae46ee8014a | |
Step 2 : RUN gem install mail | |
---> Using cache | |
---> fc1970428172 | |
Step 3 : COPY test.rb / | |
---> Using cache | |
---> cb14a9f78b13 | |
Step 4 : CMD /test.rb | |
---> Using cache | |
---> 7f41cf4adbbc | |
Successfully built 7f41cf4adbbcChristopherEvans:2.1.10-alpine christopher.evans$ docker run -it -e SMTP_DOMAIN=... -e SMTP_USERNAME=... -e SMTP_PASSWORD=... -e EMAIL_ADDRESS=... -e SMTP_CA_PATH=/etc/ssl/certs/ 2.1.10-alpine | |
ChristopherEvans:2.1.10-alpine christopher.evans$ docker run -it -e SMTP_DOMAIN=... -e SMTP_USERNAME=... -e SMTP_PASSWORD=... -e EMAIL_ADDRESS=... 2.1.10-alpine | |
/usr/local/lib/ruby/2.1.0/net/smtp.rb:586:in `connect': SSL_connect returned=1 errno=0 state=error: certificate verify failed (OpenSSL::SSL::SSLError) | |
from /usr/local/lib/ruby/2.1.0/net/smtp.rb:586:in `tlsconnect' | |
from /usr/local/lib/ruby/2.1.0/net/smtp.rb:563:in `do_start' | |
from /usr/local/lib/ruby/2.1.0/net/smtp.rb:520:in `start' | |
from /usr/local/bundle/gems/mail-2.6.4/lib/mail/network/delivery_methods/smtp.rb:113:in `deliver!' | |
from /usr/local/bundle/gems/mail-2.6.4/lib/mail/message.rb:2149:in `do_delivery' | |
from /usr/local/bundle/gems/mail-2.6.4/lib/mail/message.rb:239:in `deliver' | |
from /usr/local/bundle/gems/mail-2.6.4/lib/mail/mail.rb:141:in `deliver' | |
from /test.rb:18:in `<main>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ruby:2.1.10-alpine | |
RUN gem install mail | |
COPY test.rb / | |
CMD ["/test.rb"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'mail' | |
Mail.defaults do | |
delivery_method :smtp, { | |
address: ENV['SMTP_ADDRESS']||'smtp.sendgrid.net', | |
port: 587, | |
domain: ENV.fetch('SMTP_DOMAIN'), | |
user_name: ENV.fetch('SMTP_USERNAME'), | |
password: ENV.fetch('SMTP_PASSWORD'), | |
authentication: 'plain', | |
enable_starttls_auto: true, | |
openssl_verify_mode: ENV['SMTP_OPENSSL_VERIFY_MODE']||'peer', | |
ca_file: ENV['SMTP_CA_FILE'], | |
ca_path: ENV['SMTP_CA_PATH'] | |
} | |
end | |
Mail.deliver do | |
from ENV['EMAIL_ADDRESS'] | |
to ENV['EMAIL_ADDRESS'] | |
subject 'Testing email' | |
body 'Testing email' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment