Simple SMTP server in ruby

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?
I dont want to use any SMTP servers like ( sendmail or qmail) .I used the
code in the link as server.rb.
I tried using the following simple code

msgstr = <<END_OF_MESSAGE

···

From: joker <from@from.com>
To: some <some@somebody.com>
Subject: test message
Date: Sat, 23 Jun 2001 16:26:43 +0900
Message-Id: <unique.message.id.string@example.com>
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.

--
mad jokr

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 = <<END_OF_MESSAGE
From: joker <from@from.com>
To: some <some@somebody.com>
Subject: test message
Date: Sat, 23 Jun 2001 16:26:43 +0900
Message-Id: <unique.message.id.string@example.com>
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/\.

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.

···

On Mar 11, 3:42 pm, Brian Candler <b.cand...@pobox.com> 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 = <<END_OF_MESSAGE
> From: joker <f...@from.com>
> To: some <s...@somebody.com>
> Subject: test message
> Date: Sat, 23 Jun 2001 16:26:43 +0900
> Message-Id: <unique.message.id.str...@example.com>
> 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/.