Need Help Using Net::SMTP

D

Dan Diebolt

--0-1195016788-1135850334=:49285
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

I am trying to send email from my comcast email account (say (e-mail address removed)=
et) to my yahoo email accout (say (e-mail address removed)) from a ruby script using =
net/smtp:
=20
require 'net/smtp'
Net::SMTP.start("smtp.comcast.net", 25,"localhost","user","pass") do |smt=
p|
smtp.send_message "hello","(e-mail address removed)","(e-mail address removed)"=20
end
=20
After trying the above ruby in irb I get the following message with no =
email delivered:
=20
=3D> "250 Mail queued for delivery.\n"
=20
I don't understand how the third argument to Net::SMTP.start should be =
specified; its called "helo" and documentation says it defaults to 'local=
host.localdomain'. I would appreciate it if anyone could point out what I=
am doing wrong.
=20
I am pretty sure I have the smtp, pop3 and ports identified correctly a=
s I can send email using the command line utility postie (http://www.infr=
adig.com/postie/index.shtml):
=20
postie -esmtp -host:smtp.comcast.net -to:[email protected] -from:me@comcast.=
net -s:subject -msg:hello -user:user -pass:pass=20
=20
#Incoming mail (POP3): mail.comcast.net=20
#Incoming mail (POP3): 110
#Outgoing mail (SMTP): smtp.comcast.net=20
#Outgoing mail (SMTP): port is set to 25
=20
=20

=09
 
D

Dan Diebolt

--0-1020623145-1135855120=:46005
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
You may be getting caught by a spam filter.
=20
I can post email using postie so I can't see a problem with the basic c=
redentials being sent. There must be some configuration of Net::SMTP that=
will allow me to email from Ruby. Anyone have a clue what to do?

=09
 
K

Kero

--0-1020623145-1135855120=:46005
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable


I can post email using postie so I can't see a problem with the basic c
redentials being sent. There must be some configuration of Net::SMTP that
will allow me to email from Ruby. Anyone have a clue what to do?

$ ri send_message
------------------------------------------------- Net::SMTP#send_message
send_message( msgstr, from_addr, *to_addrs )
------------------------------------------------------------------------
Sends msgstr as a message. Single CR ("\r") and LF ("\n") found in
the msgstr, are converted into the CR LF pair. You cannot send a
binary message with this method. msgstr should include both the
message headers and body.

"...both the message headers and the body" does not seem to be covered by a
string like "hello", in other words you are complying to SMTP but not to RFC
822. Lacking a From/Reply-To address you do not receive the Delivery Failure
message, I suppose. An (incomplete!) snippet from what I use:

header = [
"To: #{to.join(', ')}",
"Subject: #{subject}",
"Date: #{Time.now.rfc822}",
"From: Arena II <#{ArenaMail}>"
]
Net::SMTP.start("localhost", 25, SiteDNS) { |smtp|
smtp.sendmail(header.join("\n")+"\n\n"+msg, ArenaMail, rcpts)
}

(in which I should use \r\n but as the docs say, it does not matter)

Hth,
Kero.

PS: there are higher level mail libraries for Ruby, iirc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

net/smtp 6
net/smtp 3
SMTP Server Connection Errno ETIMEOUT 0
net/smtp question 6
Email/SMTP::NET Problems 24
SMTP 0
Net::SMTP errors 3
Help with NET::SMTP 13

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,141
Latest member
BlissKeto
Top