send email
Peter Nuttall
pnu at ukfsn.org
Thu Sep 25 06:46:16 EDT 2003
On Thursday 25 Sep 2003 4:17 am, Ian Bicking wrote:
> On Wednesday, September 24, 2003, at 09:04 PM, Alberto Vera wrote:
> > Could you tell me How I can send an email using WIN2000? What do I
> > need?
>
> Use the smtplib module, and maybe the new email module to create the
> email message (but you won't need that if you want to create simple
> email messages).
>
> Ian
here is a program to send emails with python. It was writien quickly so it is
not perfect.
import smtplib
winth_of_email=50
message = ''
print 'type message here:'
end = 0
while end == 0:
msg=raw_input()
if msg=='':
if new_line_1=='1':
print 'end of message'
end=1
else:
new_line_1='1'
message = message + '\n'
else:
new_line_1=''
new_line_2=''
lent=len(msg)/winth_of_email
x=0
while x <= lent:
chop=(x+1) * winth_of_email+x
msg = msg[:chop] + '\n' + msg[chop:]
x+=1
message = message +'\n'+ msg
#adds headers to email
fromaddr=raw_input('what is the from address ')
toaddrs=raw_input('what is the to address ')
subject=raw_input('what is the subject ')
sever=raw_input('what is the smtp sever you are using ')
message = 'From: '+fromaddr +'\n'+ 'To: '+toaddrs +'\n'+ 'Subject '+ subject +
'\n' +message
print "Message length is " + `len(message)`
#code for sending email
server = smtplib.SMTP(sever)
server.set_debuglevel(1)
server.sendmail(fromaddr, toaddrs, message)
server.quit()
if anyone has any comments I would like to see them.
Peter
--
Someone esle can help you better than I can.
Every time I think that perhaps we are an advanced race, I turn around and
read ramblings on Slashdot, and realize I was wrong.
More information about the Python-list
mailing list