From: Brian Candler Date: 2010-03-12T05:42:28+09:00 Subject: Re: Simple SMTP server in ruby mad joker wrote: > Hi, > I was trying a simple mail smtp server in ruby. I tried the code > in > the following link > > http://snippets.dzone.com/posts/show/3932 > > I am unable to send mail to my gmail account from the server. Can you > please > tell What may be the reason? That's because a SMTP *server* receives mail. If you want to send mail, you need a SMTP *client*. > I tried using the following simple code > > > msgstr = < From: joker > To: some > Subject: test message > Date: Sat, 23 Jun 2001 16:26:43 +0900 > Message-Id: > This is a test message. > END_OF_MESSAGE > > > > require 'net/smtp' > > > > smtp = Net::SMTP.start('127.0.0.1', 25) > > smtp.send_message msgstr, 'somebofy@some.com', 'tobuddy@something.com' > > smtp.finish > > Yes my email address are changed.. But even if i give correct mail > address. > I am not able to send. What error do you get? That code sends outbound mail to a mailserver running on your local machine (127.0.0.1). Do you have one running there, e.g. sendmail, exim, postfix? If no, then you should get a fail to connect error. If yes, and the mail is sent, then you'll need to look in your mailserver logs to see why it didn't get delivered further. Or you could replace 127.0.0.1 with your ISP's SMTP relay hostname. -- Posted via http://www.ruby-forum.com/.