PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > net/smtp question
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
net/smtp question

Réponse
 
LinkBack Outils de la discussion
Vieux 14/09/2007, 05h11   #1
Michael Linfield
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut net/smtp question

Ive tried several examples from numerous books trying to send mail with
net smtp and i never really get the emails.

require 'net/smtp'

message = <<MESSAGE_END
From: Nobody <nobody@power.net>
To: Someone <someone@hotmail.com>
Subject: Test SMTP

i pray that itll work
MESSAGE_END

Net::SMTP.start('mx1.hotmail.com') do |smtp|
smtp.send_message message, 'nobody@power.net', 'someone@hotmail.com'
end

#####
This was one example, i receive no errors indicating a problem but when
checking my email IE: someone@hotmail.com i dont have it in any
folders, not inbox or junkmail.

Another version that i modified to fit my own needs was this ----

require 'net/smtp'

puts "Sender: "
sender = gets.chomp
puts "Recipient: "
rcpt = gets.chomp
puts "Message: "
msg = gets.chomp

smtp = Net::SMTP.new('mx1.hotmail.com')

smtp.start()

smtp.ready(sender, rcpt) do |mail|

mail.write msg

end

#########
once again no errors

any ideas why i might not be getting the emails?
--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Vieux 14/09/2007, 05h49   #2
Mohit Sindhwani
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: net/smtp question

Michael Linfield wrote:
> Ive tried several examples from numerous books trying to send mail with
> net smtp and i never really get the emails.
>
> require 'net/smtp'
>
> message = <<MESSAGE_END
> From: Nobody <nobody@power.net>
> To: Someone <someone@hotmail.com>
> Subject: Test SMTP
>
> i pray that itll work
> MESSAGE_END
>
> Net::SMTP.start('mx1.hotmail.com') do |smtp|
> smtp.send_message message, 'nobody@power.net', 'someone@hotmail.com'
> end
>
> #####
> This was one example, i receive no errors indicating a problem but when
> checking my email IE: someone@hotmail.com i dont have it in any
> folders, not inbox or junkmail.
>
> Another version that i modified to fit my own needs was this ----
>
> require 'net/smtp'
>
> puts "Sender: "
> sender = gets.chomp
> puts "Recipient: "
> rcpt = gets.chomp
> puts "Message: "
> msg = gets.chomp
>
> smtp = Net::SMTP.new('mx1.hotmail.com')
>
> smtp.start()
>
> smtp.ready(sender, rcpt) do |mail|
>
> mail.write msg
>
> end
>
> #########
> once again no errors
>
> any ideas why i might not be getting the emails?
>


I know I'm not directly answering your question, but there's a sample on
my blog:
http://notepad.onghu.com/ruby

I think it would be good for you to try to send it to some other email
address, perhaps, you are missing some fields which make your mail look
like spam and is being dropped by something along the way?

Cheers,
Mohit.
9/14/2007 | 12:49 PM.




  Réponse avec citation
Vieux 14/09/2007, 05h57   #3
Konrad Meyer
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: net/smtp question

--nextPart5753466.k0TFDkDMZQ
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Quoth Mohit Sindhwani on Thursday 13 September 2007 09:49:49 pm:
> Michael Linfield wrote:
> > Ive tried several examples from numerous books trying to send mail with
> > net smtp and i never really get the emails.
> >
> > require 'net/smtp'
> >
> > message =3D <<MESSAGE_END
> > From: Nobody <nobody@power.net>
> > To: Someone <someone@hotmail.com>
> > Subject: Test SMTP
> >
> > i pray that itll work
> > MESSAGE_END
> >
> > Net::SMTP.start('mx1.hotmail.com') do |smtp|
> > smtp.send_message message, 'nobody@power.net', 'someone@hotmail.com'
> > end
> >
> > #####
> > This was one example, i receive no errors indicating a problem but when
> > checking my email IE: someone@hotmail.com i dont have it in any
> > folders, not inbox or junkmail.
> >
> > Another version that i modified to fit my own needs was this ----
> >
> > require 'net/smtp'
> >
> > puts "Sender: "
> > sender =3D gets.chomp
> > puts "Recipient: "
> > rcpt =3D gets.chomp
> > puts "Message: "
> > msg =3D gets.chomp
> >
> > smtp =3D Net::SMTP.new('mx1.hotmail.com')
> >
> > smtp.start()
> >
> > smtp.ready(sender, rcpt) do |mail|
> >
> > mail.write msg
> >
> > end
> >
> > #########
> > once again no errors
> >
> > any ideas why i might not be getting the emails?
> > =20

>=20
> I know I'm not directly answering your question, but there's a sample on=

=20
> my blog:
> http://notepad.onghu.com/ruby
>=20
> I think it would be good for you to try to send it to some other email=20
> address, perhaps, you are missing some fields which make your mail look=20
> like spam and is being dropped by something along the way?
>=20
> Cheers,
> Mohit.
> 9/14/2007 | 12:49 PM.


A lot of ISPs block people from having mail servers on their local machines,
as this is something zombie networks tend to do rather than joe idiot user.

=2D-=20
Konrad Meyer <konrad@tylerc.org> http://konrad.sobertillnoon.com/

--nextPart5753466.k0TFDkDMZQ
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQBG6hSoCHB0oCiR2cwRAiM2AKCGo7+bRkxa0lZU7bpdl3 LNd5d/EgCgv7Sk
lDSFkyGj57wm++FDV1U7iu0=
=9OFZ
-----END PGP SIGNATURE-----

--nextPart5753466.k0TFDkDMZQ--

  Réponse avec citation
Vieux 14/09/2007, 09h49   #4
Peña, Botp
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: net/smtp question

RnJvbTogTWljaGFlbCBMaW5maWVsZCBbbWFpbHRvOmdsb2J5eT MwMDBAaG90bWFpbC5jb21dIA0K
IyBzbXRwID0gTmV0OjpTTVRQLm5ldygnbXgxLmhvdG1haWwuY2 9tJykNCiMgc210cC5zdGFydCgp
DQoNCnNtdHAuc2V0X2RlYnVnX291dHB1dCAkc3RkZXJyICAgIy BpbnNlcnQgdGhpcyBhbmQgZW1h
aWwgYmFjayB0aGUgcmVzdWx0DQogDQojIHNtdHAucmVhZHkoc2 VuZGVyLCByY3B0KSBkbyB8bWFp
bHwNCiMgIG1haWwud3JpdGUgbXNnDQo=

  Réponse avec citation
Vieux 14/09/2007, 11h08   #5
Dan Zwell
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: net/smtp question

Michael Linfield wrote:
> Ive tried several examples from numerous books trying to send mail with
> net smtp and i never really get the emails.
>
> require 'net/smtp'
>
> message = <<MESSAGE_END
> From: Nobody <nobody@power.net>
> To: Someone <someone@hotmail.com>
> Subject: Test SMTP
>
> i pray that itll work
> MESSAGE_END
>
> Net::SMTP.start('mx1.hotmail.com') do |smtp|
> smtp.send_message message, 'nobody@power.net', 'someone@hotmail.com'
> end
>
> #####
> This was one example, i receive no errors indicating a problem but when
> checking my email IE: someone@hotmail.com i dont have it in any
> folders, not inbox or junkmail.
>
> Another version that i modified to fit my own needs was this ----
>
> require 'net/smtp'
>
> puts "Sender: "
> sender = gets.chomp
> puts "Recipient: "
> rcpt = gets.chomp
> puts "Message: "
> msg = gets.chomp
>
> smtp = Net::SMTP.new('mx1.hotmail.com')
>
> smtp.start()
>
> smtp.ready(sender, rcpt) do |mail|
>
> mail.write msg
>
> end
>
> #########
> once again no errors
>
> any ideas why i might not be getting the emails?


Does hotmail even allow SMTP usage? I noticed you were trying to connect
to the server mx1.hotmail.com. Try this with a GMail account or other
account, it should work. The following is part of a script that worked
for me, though I haven't tested it in 6 months. Ruby 1.8 doesn't support
TLS, so I had to require a file "smtp_tls.rb" that you can find on the
web. You won't need it if your server doesn't require TLS.


#!/usr/bin/env ruby
require 'net/smtp'
require 'smtp_tls'

myMessage = <<END_OF_MESSAGE
From: XXXXXXX <your_address@gmail.com>
To: XXXXXX <someone@example.com>
Subject: XXXXX XXXXXX

This e-mail is a test.
END_OF_MESSAGE

Net::SMTP.start('smtp.gmail.com', 587, 'localhost.localdomain',
username, password, :login) do |smtp|
smtp.send_message(myMessage, 'your_address@gmail.com',
['someone@example.com']);

end

__END__

Good luck,
Dan

  Réponse avec citation
Vieux 17/09/2007, 06h48   #6
Damjan Rems
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: net/smtp question

Michael Linfield wrote:
> Ive tried several examples from numerous books trying to send mail with
> net smtp and i never really get the emails.
>
> require 'net/smtp'
>
> message = <<MESSAGE_END
> From: Nobody <nobody@power.net>
> To: Someone <someone@hotmail.com>
> Subject: Test SMTP
>
> i pray that itll work
> MESSAGE_END
>
> Net::SMTP.start('mx1.hotmail.com') do |smtp|
> smtp.send_message message, 'nobody@power.net', 'someone@hotmail.com'
> end


This example works perfectly good for me.

I would chack if server 'mx1.hotmail.com' allows message relaying.

by
TheR
--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Vieux 17/09/2007, 07h03   #7
BJ Dierkes
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: net/smtp question


On Sep 17, 2007, at 12:48 AM, Damjan Rems wrote:

> Michael Linfield wrote:
>> Ive tried several examples from numerous books trying to send mail
>> with
>> net smtp and i never really get the emails.
>>
>> require 'net/smtp'
>>
>> message = <<MESSAGE_END
>> From: Nobody <nobody@power.net>
>> To: Someone <someone@hotmail.com>
>> Subject: Test SMTP
>>
>> i pray that itll work
>> MESSAGE_END
>>
>> Net::SMTP.start('mx1.hotmail.com') do |smtp|
>> smtp.send_message message, 'nobody@power.net',
>> 'someone@hotmail.com'
>> end

>
> This example works perfectly good for me.
>
> I would chack if server 'mx1.hotmail.com' allows message relaying.


Agreed.... meaning, in your example you are assuming that
mx1.hotmail.com is allowing un-authenticated SMTP. Majority of mail
server require that you perform SMTP Auth before any outgoing
transmission can occur.



Confidentiality Notice: This e-mail message (including any attached or
embedded documents) is intended for the exclusive and confidential use of the
individual or entity to which this message is addressed, and unless otherwise
expressly indicated, is confidential and privileged information of Rackspace
Managed Hosting. Any dissemination, distribution or copying of the enclosed
material is prohibited. If you receive this transmission in error, please
notify us immediately by e-mail at abuse@rackspace.com, and delete the
original message. Your cooperation is appreciated.


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 12h36.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,16610 seconds with 15 queries