By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,486 Members | 1,024 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,486 IT Pros & Developers. It's quick & easy.

twisted mail server - SMTP AUTH extension not supported

P: n/a
I'm trying to create a mail server in Twisted.

I either get
SMTPSenderRefused
or
SMTPException: SMTP AUTH extension not supported by server.

What do I need to do to get it to work?
--- Here is the server:

from twisted.internet import reactor

from twisted import mail
import twisted.mail.mail
import twisted.mail.maildir

service = mail.mail.MailService('ExampleMail')
smtp = service.getSMTPFactory()
pop3 = service.getPOP3Factory()

domain = mail.maildir.MaildirDirdbmDomain(service, '/temp')
domain.addUser('salvador', 'gala')
service.addDomain('dali', domain)

reactor.listenTCP(25, smtp , interface='dali')
reactor.listenTCP(110, pop3 , interface='dali')

reactor.run()

--- Here is the client that tries to send an email:

import smtplib
from email.MIMEText import MIMEText
addr = 'salvador@dali'

msg = MIMEText('Body of message')
msg['From'] = addr
msg['Subject'] = 'Note to myself'
msg['To'] = addr

server = smtplib.SMTP('dali')
server.login('salvador', 'gala') # see note 1
server.sendmail(addr, addr ,msg.as_string())
server.quit()

--- Notes:

1. If I keep in the line:
server.login('salvador', 'gala') # see note 1
the client complains:
server.login('salvador', 'gala')
File "C:\Python23\lib\smtplib.py", line 546, in login
raise SMTPException("SMTP AUTH extension not supported by
server.")
SMTPException: SMTP AUTH extension not supported by server.

If I comment it out, the client complains:
SMTPSenderRefused: (451, 'Requested action aborted: error in
processing', 'salvador@dali')
and the server prints the message:
Failure: twisted.cred.error.UnhandledCredentials: No checker for
twisted.cred.credentials.IAnonymous,
twisted.cred.credentials.ICredentials
.... smtp.py:553: DeprecationWarning:
Returning None from validateFrom is deprecated. Raise
smtp.SMTPBadSender
instead
"Raise smtp.SMTPBadSender instead", DeprecationWarning"
Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hello, I have no experience in Twisted. However I'm looking for a
sendmail replacement after my exim died for no apparent reason. I bet
a python based MTA would be more easy to configure and manage. Do you
have any recommendation? Is there a lot of work to setup twisted as a
MTA?

tung

On 30 Dec 2003 11:05:53 -0800, ca**********@ukmail.com (Mark Carter)
wrote:
I'm trying to create a mail server in Twisted.

I either get
SMTPSenderRefused
or
SMTPException: SMTP AUTH extension not supported by server.

What do I need to do to get it to work?
--- Here is the server:

from twisted.internet import reactor

from twisted import mail
import twisted.mail.mail
import twisted.mail.maildir

service = mail.mail.MailService('ExampleMail')
smtp = service.getSMTPFactory()
pop3 = service.getPOP3Factory()

domain = mail.maildir.MaildirDirdbmDomain(service, '/temp')
domain.addUser('salvador', 'gala')
service.addDomain('dali', domain)

reactor.listenTCP(25, smtp , interface='dali')
reactor.listenTCP(110, pop3 , interface='dali')

reactor.run()

--- Here is the client that tries to send an email:

import smtplib
from email.MIMEText import MIMEText
addr = 'salvador@dali'

msg = MIMEText('Body of message')
msg['From'] = addr
msg['Subject'] = 'Note to myself'
msg['To'] = addr

server = smtplib.SMTP('dali')
server.login('salvador', 'gala') # see note 1
server.sendmail(addr, addr ,msg.as_string())
server.quit()

--- Notes:

1. If I keep in the line:
server.login('salvador', 'gala') # see note 1
the client complains:
server.login('salvador', 'gala')
File "C:\Python23\lib\smtplib.py", line 546, in login
raise SMTPException("SMTP AUTH extension not supported by
server.")
SMTPException: SMTP AUTH extension not supported by server.

If I comment it out, the client complains:
SMTPSenderRefused: (451, 'Requested action aborted: error in
processing', 'salvador@dali')
and the server prints the message:
Failure: twisted.cred.error.UnhandledCredentials: No checker for
twisted.cred.credentials.IAnonymous,
twisted.cred.credentials.ICredentials
... smtp.py:553: DeprecationWarning:
Returning None from validateFrom is deprecated. Raise
smtp.SMTPBadSender
instead
"Raise smtp.SMTPBadSender instead", DeprecationWarning"


Jul 18 '05 #2

P: n/a
On Tue, Dec 30, 2003 at 11:05:53AM -0800, Mark Carter wrote:
I'm trying to create a mail server in Twisted.

I either get
SMTPSenderRefused
or
SMTPException: SMTP AUTH extension not supported by server.

What do I need to do to get it to work?


--- Here is the server:

from twisted.internet import reactor

from twisted import mail
import twisted.mail.mail
import twisted.mail.maildir

service = mail.mail.MailService('ExampleMail')
If you want unauthenticated users to be able to send mail, you need to
explicitly allow it.

from twisted.cred import checkers
service.smtpPortal.registerChecker(checkers.AllowA nonymousAccess())
smtp = service.getSMTPFactory()
SMTP AUTH is really part of ESMTP. Try service.getESMTPFactory() instead
of service.getSMTPFactory().
pop3 = service.getPOP3Factory()

domain = mail.maildir.MaildirDirdbmDomain(service, '/temp')
domain.addUser('salvador', 'gala')
service.addDomain('dali', domain)

reactor.listenTCP(25, smtp , interface='dali')
reactor.listenTCP(110, pop3 , interface='dali')

reactor.run()


Also, note that the above code accomplishes roughly the same thing as the
following command line:

mktap mail --maildirdbmdomain dali=/temp --default \
--user salvador=gala \
--pop3 110 --smtp 25
If you just want a mail server, using the command line is probably better.
If you need more flexibility than it can offer, sticking with code is the
right choice.

Jp

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/8flAedcO2BJA+4YRAozlAJwKtrK2XkU7x7bwsoF3wzJCYVtpdw CfQItW
Kc9boapuEm+VlO3y+pRE9X4=
=9YQC
-----END PGP SIGNATURE-----

Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.