S
Satish Talim
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:<[email protected]>'
puts t.gets
t.puts 'RCPT TO:<[email protected]>'
puts t.gets
t.puts 'DATA'
puts t.gets
t.puts 'Test Email from Ruby'
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 (e-mail address removed) Address Okay
250 (e-mail address removed) Address Okay
354 Start mail input; end with <CRLF>.<CRLF>
nil
email.rb:15:in `write': Invalid argument (Errno::EINVAL)
from email.rb:15:in `puts'
from email.rb:15
I am unable to figure out what the problem is. All help appreciated.
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:<[email protected]>'
puts t.gets
t.puts 'RCPT TO:<[email protected]>'
puts t.gets
t.puts 'DATA'
puts t.gets
t.puts 'Test Email from Ruby'
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 (e-mail address removed) Address Okay
250 (e-mail address removed) Address Okay
354 Start mail input; end with <CRLF>.<CRLF>
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.