From: Satish Talim Date: 2006-08-01T10:53:44+09:00 Subject: Re: TCPSocket and RFC 821 ------=_Part_96409_5668617.1154397218888 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Yohanes, you are right. The RFC's and specifically which ones to use are a bit confusing. I read thro' RFC's 1869, 2554, 2821 and 3207 but am still not clear of the exact sequence of commands to be executed while using TCPSocket. I searched Google but did not find a specific solution. Still searching... I am abonding the local relay server and now trying to connect to the remote ESMTP server that requires authentication. On 7/31/06, Yohanes Santoso wrote: > > "Satish Talim" writes: > > > 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. > > > Could it be that the SMTP server (relay or not), does a running > verification for the content of the data? > > That is, if the data is not in RFC822 format, then it aborts the > connection ungracefully. > > Or, could it be aborting the connection because you don't authenticate > when using the TCPSocket version? > > YS. > > > > > > > > > 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/ > > -- Satish Talim http://www.puneruby.com/blog/ ------=_Part_96409_5668617.1154397218888--