Forum: Ruby net/smtp question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Fe57662c550fb3cce44c398ddf2dd706?d=identicon&s=25 itsme213 (Guest)
on 2005-11-23 02:06
(Received via mailing list)
I am experimenting with SMTP mail from my local machine, to basically
send
an email just like my Outlook client does. But I can't figure out how to
translate my Outlook settings to the parameters of SMTP.start, in
particular
the params:

  helo  : I don't see such a setting in Outlook. I use a cable service
provider for internet connection, the SMTP server is different (at my
web
host).

  user  : is this the User Name from the Outlook account?

  secret : is this the Password from the Outlok account?

  authtype : my Outlook account has "requires authentication" OFF

Thanks!



require 'net/smtp'

msg = "Subject: Test\n\nNow is the time\n"

Net::SMTP.start('my.smtp.server,25,'my.cable.provider','my.user.name,
 'password,:plain) do |smtp|
  # smtp.send_message msg, 'desmond.dsouza@kinetium.com',
['dedoig213@hotmail.com']
 end


C:experiments> c:/ruby/lib/ruby/1.8/net/smtp.rb:586:in `auth_login': 535
authorization failed (#5.7.0) (Net::SMTPAuthenticationError)
 from c:/ruby/lib/ruby/1.8/net/smtp.rb:571:in `__send__'
 from c:/ruby/lib/ruby/1.8/net/smtp.rb:571:in `authenticate'
 from c:/ruby/lib/ruby/1.8/net/smtp.rb:411:in `do_start'
 from c:/ruby/lib/ruby/1.8/net/smtp.rb:378:in `start'
 from c:/ruby/lib/ruby/1.8/net/smtp.rb:316:in `start'
 from C:/des/desktop/methods/experiments/smtp.rb:5
Process ruby exited with code 1
19f65b7dca6831edf989224b5ebd3fe0?d=identicon&s=25 tsumeruby (Guest)
on 2005-11-23 04:51
(Received via mailing list)
On Wednesday 23 November 2005 10:02 am, itsme213 wrote:
> I am experimenting with SMTP mail from my local machine, to basically send
> an email just like my Outlook client does. But I can't figure out how to
> translate my Outlook settings to the parameters of SMTP.start, in
> particular the params:
>
>   helo  : I don't see such a setting in Outlook. I use a cable service
> provider for internet connection, the SMTP server is different (at my web
> host).

You are a client, you still need to use the correct HELO.

HELO myhostname-12-34-34-2.myisp.com

would be what you want to say to server, just supply hostname.

Here is an example SMTP session to my mail server using one of the
number one
administration utilities.. telnet :)

tsume@laptop:~$ telnet tsumelabs.com 25
Trying 72.21.54.43...
Connected to tsumelabs.com.
Escape character is '^]'.
220 zanshin.tsumelabs.com ESMTP
HELO FAKEDOMAIN.COM
250 zanshin.tsumelabs.com Ok.
EHLO FAKEDOMAIN.COM
250-zanshin.tsumelabs.com Ok.
250-AUTH LOGIN CRAM-MD5 CRAM-SHA1 CRAM-SHA256
250-AUTH=LOGIN CRAM-MD5 CRAM-SHA1 CRAM-SHA256 X-NETSCAPE-HAS-BUGS
250-XVERP=Courier
250-XEXDATA
250-XSECURITY=NONE,STARTTLS
250-PIPELINING
250-8BITMIME
250-SIZE
250 DSN
MAIL FROM:<tsume@hidedomain.com>
250 Ok.
RCPT TO:<tsume@tsumelabs.com>
250 Ok.
DATA
354 Ok.
Subject: Test Message
From: tsume@hidedomain.com

test

.
250 Ok. 43838FA9.000017BC
quit
221 Bye.


When the email is delivered, the email is altered by the MTA.
Below is what the client(I) get when I check my mail via POP3.
[start]
------------------------------------------------------------------

Delivered-To: tsume@tsumelabs.com
Return-Path: <tsume@hidedomain.com>
Received: from FAKEDOMAIN.COM ([209.112.145.186])
  by zanshin.tsumelabs.com with esmtp; Tue, 22 Nov 2005 16:37:17 -0500
  id 0068813E.43838FA9.000017BC
Subject: Test Message
To: tsume@tsumelabs.com
From: tsume@hidedomain.com
Message-ID: <courier.43838F8D.000017BC@zanshin.tsumelabs.com>
Date: Tue, 22 Nov 2005 16:37:17 -0500

test

[end] ---------------------------------------

Notice the received from line

Received: from FAKEDOMAIN.COM ([209.112.145.186])
Still the MTA will place my IP address in the header, I'm really on

tsume@laptop:~$ nslookup 209.112.145.186
Server:         209.193.4.7
Address:        209.193.4.7#53

186.145.112.209.in-addr.arpa    name =
209-112-145-186-cdsl-rb1.sol.acsalaska.net.

tsume@laptop:~$

Many spammers fake the HELO, and I know some MTAs actually do check for
a
valid HELO, so you want to use the correct hostname.

Do I still need to provide a helo if I send the email to my ISPs server?
yes, the mail server still attaches receive. Look through emails and you
will
see more of how the MTA will transform emails, here is an example

[start]
------------------------------------------------------------------

Delivered-To: tsume@tsumelabs.com
Return-Path: <tsume@hidedomain.com>
Received: from FAKEDOMAIN.COM ([209.112.145.186])
  by zanshin.tsumelabs.com with esmtp; Tue, 22 Nov 2005 16:37:17 -0500
  id 0068813E.43838FA9.000017BC
Received: from littleguy-23.2.32.3.isp.com ([205.2.145.186])
  by some-otherhost.com with esmtp; Tue, 22 Nov 2005 16:34:17 -0500
  id 0068813E.43838FA9.000017BC
Subject: Test Message
To: tsume@tsumelabs.com
From: tsume@hidedomain.com
Message-ID: <courier.43838F8D.000017BC@zanshin.tsumelabs.com>
Date: Tue, 22 Nov 2005 16:37:17 -0500

test

[end] ---------------------------------------

Ask more questions if confused.

There are RFCs on SMTP you should read for future reference

http://www.rfc-editor.org/

Have more fun learning!

Tsume

>
>   user  : is this the User Name from the Outlook account?
>

yes, this may be your email name, or your full email address

>   secret : is this the Password from the Outlok account?
>

yes
Fe57662c550fb3cce44c398ddf2dd706?d=identicon&s=25 itsme213 (Guest)
on 2005-11-23 20:00
(Received via mailing list)
I tried <my_host>-12-34-34-2.myisp.com and it failed.

Then ... Ouch! I just tried removing my email login, password, and even
HELO
info:

msg = "Subject: Test\n\nNow is the time\n"

Net::SMTP.start('smtp.server',25) do |smtp|
  smtp.send_message msg, 'a.valid.email.address@server.com,
['receiver.address@receiver.com]
end

And it went through fine. I am a bit taken aback that there appears to
be no
checking done at all. Is this normal?

Thanks!

"Tsume" <tsumeruby@tsumelabs.com> wrote in message
news:200511231248.14181.tsumeruby@tsumelabs.com...
457cf540784a12ba2f30e06565a2c189?d=identicon&s=25 hgs (Guest)
on 2005-11-23 20:12
(Received via mailing list)
On Thu, 24 Nov 2005, itsme213 wrote:

> end
>
> And it went through fine. I am a bit taken aback that there appears to be no
> checking done at all. Is this normal?
>
> Thanks!

Going by the headers in that message:

 Received: from localhost ([127.0.0.1] helo=localhost.localdomain)
    by sinus.lauschmusik.de with esmtp (Exim 4.50)
    id 1Eezll-00068m-O3
    for ruby-talk@ruby-lang.org; Wed, 23 Nov 2005 19:55:01 +0100

your smtp host is running exim, which will figure most of this out
anyway. and it depends how much checking the admin has put into the
config as to what is and what is not accepted.

        http://www.exim.org
for more than you wanted to know about this.

        Hugh
19f65b7dca6831edf989224b5ebd3fe0?d=identicon&s=25 tsumeruby (Guest)
on 2005-11-23 23:34
(Received via mailing list)
On Thursday 24 November 2005 03:57 am, itsme213 wrote:
> I tried <my_host>-12-34-34-2.myisp.com and it failed.
>
> Then ... Ouch! I just tried removing my email login, password, and even
> HELO info:
>

Most ISPs will just have the SMTP server open to all clients on their
network.
Meaning you probably don't need authentication applied to your script.
The
HELO is supposed to work however, what is the fail message? the HELO is
supposed to be applied as the RFC states, but I really doubt it is
failing.
The HELO is defaulted to localhost.localdomain if you don't supply an
argument for the HELO in net/smtp.rb

The example I shown was me communicating with my server, which I
definitely
don't route through for the internet :)

> msg = "Subject: Test\n\nNow is the time\n"
>
> Net::SMTP.start('smtp.server',25) do |smtp|
>   smtp.send_message msg, 'a.valid.email.address@server.com,
> ['receiver.address@receiver.com]
> end
>
> And it went through fine. I am a bit taken aback that there appears to be
> no checking done at all. Is this normal?
>

I'm guessing the SMTP server was choking at the authentication.


Tsume
This topic is locked and can not be replied to.