Saari Development

Ali Rizvi's Technical Blog as a Professional Software Development Engineer

Ruby: net/smtp weirdness – to address can’t contain dash/hyphen (-)

leave a comment »

This caused me a lot of grief and debugging time.

I am using code like this to send emails from a CGI script:

    Net::SMTP.start('', 25) do |smtp|
      smtp.open_message_stream('', ['']) do |f|
        f.puts 'From:'
        f.puts 'To:'
        f.puts 'Cc:'
        f.puts 'Subject: test message'
        f.puts 'This is a test message.'

and this is failing silent in my case.

I have discovered through trial and error that if I remove the -(dash) from the to address it works. Dashes in from or CC addresses does not matter.


Written by imsaar

October 3, 2007 at 12:15 am

Posted in code, ruby

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: