Afficher un message
Vieux 03/08/2007, 18h38   #3
hg
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: envoi d'un fichier.txt par mail

fred1599@gmail.com wrote:

> Bonjour,
>
> Voila le probleme j'ai créé un fichier.txt et je voudrais l'envoyer
> par mail sur ma boite orange.
>
> Pouvez-vous m'aider s'il vous plait?
>
> Merci par avance



J'utilise ce type de code pour envoyer un message à une liste de distrib:


import smtplib
from email.MIMEText import MIMEText

to_list = [ \
'toto@nospam.com', \
'titi@nospam.com'
]

the_text = 'CECI EST RECUPERE DU FICHIER TEXTE' #file.read()
me = 'me@nospam.com'
msg = MIMEText(the_text)
msg['Subject'] = 'MON SUJET'
msg['From'] = me
host = 'smtp.server.com'
s = smtplib.SMTP()



print 'CONNECTING TO HOST'
s.connect(host)
print 'LOGGING TO HOST'
s.login('me@nospam.com','motdepasse')

for you in to_list:
msg['To'] = you
print 'SENDING MAIL TO: ' + you
s.sendmail(me, [you], msg.as_string())
print 'CLOSING CONNECTION'
s.close()


hg




  Réponse avec citation
 
Page generated in 0,05324 seconds with 9 queries