The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
smtp_tls 1.0.3

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Eric Hodel

Posts: 660
Nickname: drbrain
Registered: Mar, 2006

Eric Hodel is a long-time Rubyist and co-founder of Seattle.rb.
smtp_tls 1.0.3 Posted: Jul 8, 2009 5:39 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Eric Hodel.
Original Post: smtp_tls 1.0.3
Feed Title: Segment7
Feed URL: http://blog.segment7.net/articles.rss
Feed Description: Posts about and around Ruby, MetaRuby, ruby2c, ZenTest and work at The Robot Co-op.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Eric Hodel
Latest Posts From Segment7

Advertisement

Provides SMTP STARTTLS support for Ruby 1.8.6 (built-in for 1.8.7+). Simply require ‘smtp_tls’ and use the Net::SMTP#enable_starttls method to talk to servers that use STARTTLS.

  require 'net/smtp'
  begin
    require 'smtp_tls'
  rescue LoadError
  end

  smtp = Net::SMTP.new address, port
  smtp.enable_starttls
  smtp.start Socket.gethostname, user, password, authentication do |server|
    server.send_message message, from, to
  end

You can also test your SMTP connection settings using mail_smtp_tls:

  $ date | mail_smtp_tls smtp.example.com submission \
    "your username" "your password" plain \
    from@example.com to@example.com
  Using SMTP_TLS 1.0.3
  -> "220 smtp.example.com ESMTP XXX\r\n"
  <- "EHLO you.example.com\r\n"
  -> "250-smtp.example.com at your service, [192.0.2.1]\r\n"
  -> "250-SIZE 35651584\r\n"
  -> "250-8BITMIME\r\n"
  -> "250-STARTTLS\r\n"
  -> "250-ENHANCEDSTATUSCODES\r\n"
  -> "250 PIPELINING\r\n"
  <- "STARTTLS\r\n"
  -> "220 2.0.0 Ready to start TLS\r\n"
  TLS connection started
  <- "EHLO you.example.com\r\n"
  -> "250-smtp.example.com at your service, [192.0.2.1]\r\n"
  -> "250-SIZE 35651584\r\n"
  -> "250-8BITMIME\r\n"
  -> "250-AUTH LOGIN PLAIN\r\n"
  -> "250-ENHANCEDSTATUSCODES\r\n"
  -> "250 PIPELINING\r\n"
  <- "AUTH PLAIN BASE64_STUFF_HERE\r\n"
  -> "235 2.7.0 Accepted\r\n"
  <- "MAIL FROM:<from@example.com>\r\n"
  -> "250 2.1.0 OK XXX\r\n"
  <- "RCPT TO:<to@example.com>\r\n"
  -> "250 2.1.5 OK XXX\r\n"
  <- "DATA\r\n"
  -> "354  Go ahead XXX\r\n"
  writing message from String
  wrote 91 bytes
  -> "250 2.0.0 OK 1247028988 XXX\r\n"
  <- "QUIT\r\n"
  -> "221 2.0.0 closing connection XXX\r\n"

This will connect to smtp.example.com using the submission port (port 587) with a username and password of “your username” and “your password” and authenticate using plain-text auth (the submission port always uses SSL) then send the current date to to@example.com from from@example.com.

Debug output from the connection will be printed on stderr.

Changes:

  • 1 minor enhancement
    • Added mail_smtp_tls executable to test SMTP connections
  • 2 bug fixes
    • Suppress default DH parameters warning
    • Pass debug output down to child IOs

Read: smtp_tls 1.0.3

Topic: Swingin' Safari Previous Topic   Next Topic Topic: imap_processor 1.2

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use