[Twisted-Python] how to authenticate SMPT server in Twisted Framework

Jean-Paul Calderone exarkun at divmod.com
Fri May 8 07:44:22 EDT 2009

On Thu, 7 May 2009 15:20:12 +0530, ganesh gunasekaran <gjango.py at gmail.com> wrote:
>Hi gp,
>I'm very new to Twisted Framework ,
>I wrote a very simple  code to send mails concurrently, using SMTP mail
>the code as below
>from twisted.mail.smtp import sendmail
>from twisted.internet import reactor
>from twisted.python.log import err
>import time
>MAILSERVER = 'mail.xxx.com'
>listTo = ['ganesh.xxx at gmail.com', 'xxjango.py at gmail.com', '
>lovely_xxx at yahoo.co.in']
>FROM = 'gxxxkaran at xxxx.com'
>MSGBODY = "hi this is test mail"
>a= time.time()
>done = sendmail(MAILSERVER, FROM, listTo, MSGBODY ,senderDomainName=None,
>done.addCallback(lambda ignored: reactor.stop())
>print "Took %s seconds" %str(time.time()-a)
>hence i'm not aware of how to authenticate my mail server in Twisted
>Framework ,this code gives me error saying ,"Relay access denied"
>I will be grateful  if someone forward me the right solution.

`sendmail´ can't be used to authenticate.  For that, you need to use
`ESMTPSenderFactory`.  It takes many of the same arguments as `sendmail´,
plus a `username´ and `password´ and some options related to security.

If you haven't worked with factories before, the client howto might be



More information about the Twisted-Python mailing list