Skip to content

Instantly share code, notes, and snippets.

@pjb3
Created March 29, 2012 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pjb3/2236751 to your computer and use it in GitHub Desktop.
Save pjb3/2236751 to your computer and use it in GitHub Desktop.
Running this with mailcatcher results in a "503 MAIL already given"
#!/usr/bin/env ruby
require 'net/smtp'
require 'time'
def send_message(smtp, from, to)
msg = %{From: #{from}
To: #{to}
Subject: test message
Date: #{Time.now.rfc2822}
Message-Id: <#{Time.now.to_f}@example.com>
This is a test message.
}
smtp.send_message(msg, from, to)
end
Net::SMTP.start('localhost', 1025) do |smtp|
send_message(smtp, 'from@example.com', 'to1@example.com')
send_message(smtp, 'from@example.com', 'to2@example.com')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment