From: pharrington Date: 2010-03-12T07:05:06+09:00 Subject: Re: Simple SMTP server in ruby On Mar 11, 3:42 pm, Brian Candler wrote: > 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, 'someb...@some.com', 'tobu...@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 viahttp://www.ruby-forum.com/. An SMTP server definitely sends email. However two problems... 1) If you just copy/pasted the code from that page, the server is listening on port 1234, while you're trying to connect to port 25. 2) *THAT* server does not actually send email. It's not meant to send email; the code seem more a simple example of how to use GSever.