help using smtplib to work ..

NicolasG nicolasg at gmail.com
Wed Nov 8 18:31:27 EST 2006


> <snip from Gmail SMTP setup instructions>
>
> Under outgoing mail smtp server, use smtp.gmail.com. Since it requires SMTP
> authorization, use your Gmail account as username (e.g. yourname at gmail.com) and
> your Gmail password as password. You can turn TSL on or off.
>
> <end snip>
>
> The email server requires authentication before it can send.
> Normally this can be accomplished either by calling
>
Actually I used alt1.gmail-smtp-in.l.google.com for a server I don't
need authentication. The problem is that for some mail addresses I can
send mail's while for other's I can't . I don't know how to explained
that.....

> server.login(userid, password)
>
> The only alternative is to use an open relay email server that allows
> you to send without authenticating.  Hope info at least points you in
> the right direction.
>
the code bellow worked fine to me :

import smtplib

fromaddr = 'nicolasg at gmail.com'
toaddrs  = 'nicolasg at gmail.com'
subject = 'someting for subject !'

msg = 'This is body of the mail.'

msg = 'From: ' + fromaddr + '\nTo: ' + toaddrs + '\nSubject: ' +
subject + '\n\n' + msg
print "Message length is " + repr(len(msg))

server = smtplib.SMTP('alt1.gmail-smtp-in.l.google.com')
#'smtp.gmail.com')
server.set_debuglevel(1)
server.sendmail(fromaddr, toaddrs, msg)
server.quit()

cheers.




More information about the Python-list mailing list