From: Satish Talim Date: 2006-07-31T15:23:49+09:00 Subject: Re: TCPSocket and RFC 821 ------=_Part_62899_15054357.1154327022685 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Like I said before I am using a relay SMTP server called 1st SMTP server on my Windows XP. The code using TCPSocket does not do authenticate and as such I am not using our actual SMTP server. Since you asked for the code using Net::SMTP class, I have pasted it here - # rubysmtp.rb require 'net/smtp' user_from = "abc@puneruby.com" user_to = "abc@gmail.com" the_email = "From: abc@puneruby.com\nSubject: Hello\n\nEmail by Ruby.\n\n" # handling exceptions begin Net::SMTP.start('auth.smtp.1and1.co.uk', 25, 'auth.smtp.1and1.co.uk', 'abc@puneruby.com', 'password', :login) do |smtpclient| smtpclient.send_message(the_email, user_from, user_to) end rescue Exception => e print "Exception occured: " + e end On 7/31/06, Yohanes Santoso wrote: > > "Satish Talim" writes: > > > I tried the various suggestions given by Francis and Yohanes, but still > it > > does not work. > > > > The executable code now is: > > > > require 'socket' > > t = TCPSocket.new('localhost', 25) > > puts t.gets > > t.puts "HELO Welcome from Ruby\r\n" > > puts t.gets > > t.puts "MAIL FROM:\r\n" > > puts t.gets > > t.puts "RCPT TO:\r\n" > > puts t.gets > > t.puts 'DATA' > > puts t.gets > > t.puts "Test email from ruby\r\n" > > t.puts "\r\n.\r\n" > > t.puts 'QUIT' > > puts t.gets > > t.close > > > > and the output is: > > > >>ruby email.rb > > 220 Welcome to the 1st SMTP Server > > > > 250 Hello Welcome from Ruby > > > > 250 satish_talim@yahoo.com Address Okay > > > > 250 satish.talim@gmail.com Address Okay > > > > 354 Start mail input; end with . > > > > nil > >>Exit code: 0 > > /tmp $ ruby try.rb > 220 jenny-gnome.dyndns.org ESMTP > 250 jenny-gnome.dyndns.org > 250 ok > 250 ok > 354 go ahead > 250 ok 1154319423 qp 25461 > /tmp $ > > What is your SMTP server? > > > I'd appreciate any other suggestions. Incidentally, if I write a program > > using the Net::SMTP class, I am able to send off emails with my current > > configuration. > > Please paste this code that uses Net::SMTP. > > YS. > > -- Satish Talim http://www.puneruby.com/blog/ ------=_Part_62899_15054357.1154327022685--