From: Yohanes Santoso Date: 2006-07-31T02:43:51+09:00 Subject: Re: TCPSocket and RFC 821 "Satish Talim" writes: > I wanted to send an email from my desktop using a simple Ruby program. > I installed 1st SMTP Server > (http://www.emailarms.com/products/1st_smtp.html) - an easy to use > SMTP mail relay server. It is used for relaying your email messages to > its destinations quickly and easily. For this server, I need to use > localhost and port 25 on my PC. > > Then the program I wrote was (based on RFC 821) - > > require 'socket' > t = TCPSocket.new('localhost', 25) > puts t.gets > t.puts 'HELO Welcome from Ruby' > puts t.gets > t.puts 'MAIL FROM:' > puts t.gets > t.puts 'RCPT TO:' > puts t.gets > t.puts 'DATA' > puts t.gets > t.puts 'Test Email from Ruby' t.puts "test email from ruby\r\n" > t.puts "\r\n.\r\n" > puts t.gets > t.puts 'QUIT' > puts t.gets > t.close > > However, while running the program, I get an error as follows: > > 220 Welcome to the 1st SMTP Server > > 250 Hello Welcome from Ruby > > 250 abc@gmail.com Address Okay > > 250 abc@gmail.com Address Okay > > 354 Start mail input; end with . > > nil > email.rb:15:in `write': Invalid argument (Errno::EINVAL) > from email.rb:15:in `puts' > from email.rb:15 >>Exit code: 1 > > I am unable to figure out what the problem is. All help appreciated.