I modified this example<br><a href="http://twistedmatrix.com/projects/mail/documentation/tutorial/smtpclient/smtpclient-7.tac">http://twistedmatrix.com/projects/mail/documentation/tutorial/smtpclient/smtpclient-7.tac</a><br>
<br>I am still not completely clear on what is happening <br><br>Thanks for the help<br>Alvin<br><br><br>import StringIO<br><br>from twisted.application import service<br><br>application = service.Application("SMTP Client Tutorial")
<br><br>from twisted.application import internet<br>from twisted.internet import protocol<br>from twisted.mail import smtp<br>from twisted.mail.imap4 import CramMD5ClientAuthenticator<br><br>class SMTPTutorialClient(smtp.ESMTPClient
):<br> mailFrom = "<a href="mailto:from@sender.com">from@sender.com</a>"<br> mailTo = "<a href="mailto:to@dest.com">to@dest.com</a>"<br> mailData = '''\<br>Date: Fri, 6 Feb 2006 10:14:39 -0800
<br>From: <a href="mailto:from@sender.com">from@sender.com</a><br>To: <a href="mailto:to@dest.com">to@dest.com</a><br>Subject: Tutorate!<br><br>Hello, how are you, goodbye.<br>'''<br><br> def getMailFrom(self):<br> result =
self.mailFrom<br> self.mailFrom = None<br> return result<br><br> def getMailTo(self):<br> return [self.mailTo]<br><br> def getMailData(self):<br> return StringIO.StringIO(self.mailData)<br>
<br> def sentMail(self, code, resp, numOk, addresses, log):<br> print 'Sent', numOk, 'messages'<br><br>class SMTPClientFactory(protocol.ClientFactory):<br> protocol = SMTPTutorialClient<br><br> def buildProtocol(self, addr):
<br> return self.protocol(secret=None, identity='<a href="http://sender.com">sender.com</a>')<br><br>class SMTPClientFactory(protocol.ClientFactory):<br> protocol = SMTPTutorialClient<br> #def __init__(self, *a, **kw):
<br> # self.a, <a href="http://self.kw">self.kw</a> = a, kw<br><br> def buildProtocol(self, addr):<br> p = smtp.ESMTPClient('smtp_pw')<br> p.factory = self<br> p.requireAuthentication = True<br>
p.authenticators = {'CRAM-MD5': CramMD5ClientAuthenticator('smtp_user')}<br> return p<br><br>smtpClientFactory = SMTPClientFactory()<br><br>smtpClientService = internet.TCPClient('<a href="http://smtp.1and1.com">
smtp.1and1.com</a>', 25, smtpClientFactory)<br>smtpClientService.setServiceParent(application)<br><br><br><div><span class="gmail_quote">On 11/3/06, <b class="gmail_sendername">Jean-Paul Calderone</b> <<a href="mailto:exarkun@divmod.com">
exarkun@divmod.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">On Fri, 3 Nov 2006 16:17:15 -0800, Alvin Wang <<a href="mailto:alvinwang@gmail.com">
alvinwang@gmail.com</a>> wrote:<br>>Hi,<br>><br>>I am new to twisted but google and the Oreilly book have failed me. I am<br>>trying to create a client to send to a smtp server. All the examples that I<br>
>have found only work if your SMTP server does not require authentication.<br>><br>>I am guessing that I need to use<br>><a href="http://twistedmatrix.com/documents/current/api/twisted.mail.smtp.ESMTPSenderFactory.html">
http://twistedmatrix.com/documents/current/api/twisted.mail.smtp.ESMTPSenderFactory.html</a><br>><br>><br>>Unfortunately, I can find no examples that use it.<br>><br>>I did find something from 2004<br>><a href="http://twistedmatrix.com/pipermail/twisted-python/2004-April/007433.html">
http://twistedmatrix.com/pipermail/twisted-python/2004-April/007433.html</a><br><br>This should still work.<br><br>><br>>That is prior to the commit for ESMTPSenderFactory<br>><a href="http://twistedmatrix.com/pipermail/twisted-commits/2004-July/011608.html">
http://twistedmatrix.com/pipermail/twisted-commits/2004-July/011608.html</a><br><br>This changed ESMTPSenderFactory, but authentication was supported before<br>this commit. Give the code at the previous URL a try and post again if
<br>you run into problems.<br><br>Jean-Paul<br><br>_______________________________________________<br>Twisted-Python mailing list<br><a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br></blockquote></div><br><br>