Hi, I've noticed that sending mail from within Zope the <sendmail> tab or mailhost.send() is very slow (like it adds a few seconds to the time it takes to get a page back from a post). Why is that? how can I make it faster? I'd thought about having the actual mail sending done in a different thread/process but I don't know how I'd do that or whether it'd be worth doing. I wonder where the slowness is coming from :S cheers, Chris
Chris Withers wrote:
Hi,
I've noticed that sending mail from within Zope the <sendmail> tab or mailhost.send() is very slow (like it adds a few seconds to the time it takes to get a page back from a post).
Why is that? how can I make it faster?
I'd thought about having the actual mail sending done in a different thread/process but I don't know how I'd do that or whether it'd be worth doing. I wonder where the slowness is coming from :S
i was think about this in regard to doing bulk email, the best i could think of was to response.write and than send the email. no real confirmation but the user gets the page and the mail hopefully gets sent. i was planning on doing this from python with either calls to the mailhost or smtplib. Kapil
Kapil Thangavelu wrote:
sent. i was planning on doing this from python with either calls to the mailhost or smtplib.
MailHost uses smptlib now, IIRC It's the call to mailhost.send() which is slow. I'd love to know why :S How much influence does the the mail server speed have to this? How can I measure it? ;-) cheers, Chris
Chris Withers wrote:
It's the call to mailhost.send() which is slow. I'd love to know why :S
How much influence does the the mail server speed have to this? How can I measure it? ;-)
Set up Sendmail on localhost and see if the problem goes away. Sendmail (and most other mail servers) will queue the mail without holding up the connection. I don't know about you, but I get instantaneous mail processing this way. Shane
Shane Hathaway wrote:
It's the call to mailhost.send() which is slow. I'd love to know why :S
How much influence does the the mail server speed have to this? How can I measure it? ;-)
Set up Sendmail on localhost and see if the problem goes away.
localhost is a windows NT workstation ;-)
Sendmail (and most other mail servers) will queue the mail without holding up the connection. I don't know about you, but I get instantaneous mail processing this way.
Hmm, I think our mailserver, which I was using for this, does a DNS check on the domain names to make sure they exist. I wonder if this is what is causing the slowness of the response? cheers, Chris
Chris Withers wrote:
localhost is a windows NT workstation ;-) ^^^^^^^^^^
This is the real problem and you know it. ;-)
Hmm, I think our mailserver, which I was using for this, does a DNS check on the domain names to make sure they exist. I wonder if this is what is causing the slowness of the response?
Very possibly. Manually add some entries to the HOSTS file and see if things don't get a little snappier. Shane
Kapil Thangavelu wrote:
i was think about this in regard to doing bulk email, the best i could think of was to response.write and than send the email. no real confirmation but the user gets the page and the mail hopefully gets sent. i was planning on doing this from python with either calls to the mailhost or smtplib.
What we really want is a non-blocking MailHost. Anyone know how or want to write one? cheers, Chris
Chris Withers wrote:
Kapil Thangavelu wrote:
i was think about this in regard to doing bulk email, the best i could think of was to response.write and than send the email. no real confirmation but the user gets the page and the mail hopefully gets sent. i was planning on doing this from python with either calls to the mailhost or smtplib.
What we really want is a non-blocking MailHost.
Anyone know how or want to write one?
first, lets gather some requirements... probably best done on a fishbowl wikis... any volunteers?:) what do you mean by non-blocking MailHost, the smtplib.py waits for a reply to see if it should raise an error, but thats it as far as block that i see, i pretty much regard that as nonblocking and proper. if you're looking for send which doesn't check for reply than you could just hack smtplib but i doubt you'd see any performance benefit. assuming that smtplib and Mailhost are nonblocking... then the question becomes how to make it suitable for bulk emails and what are the requirements? do you want a mailhost that isn't connected to via a publishing thread? ie is it a requirement that processing won't affect a zope site and no response will be sent back to zope for messages processed (although an xml-rpc callback is possible). do you want to get respones back for messages you've sent? if this going to be added as a general zope feature its probably best to add some sort of mail queue, that can be added to by other zope objects. this would also avoid the overhead of connecting to the mailserver on every mail send. does it need to be multi=platform? (ie no cron, no popen2) if its for squishdot i guess i can assume the answer to this and my next question are yes. are zope/python solutions preferred? i ask because i've been considering a zope bridge into JServ which has an enterprise capable email system in James (http://java.apache.org/james/) a quick stab at portable implementation outside of zope would bundle a python script to be called by popen2 on Unix or spawnv on Windows that would read a pickle of email data and send it. course its ugly but it would work, could even get fancy and do it with an asyncore. another quick stab, if you assume the existence of xron, you could store email messages to be sent and a list of addrs to which they should be sent and xron it to be sent some other time. one possible (minor) speed improvement depending on the protocol def and the various server implementation is to mantain an open socket to the server as part of the MailHost, or at least maintain for as long as possible before getting a new connection. i need to sleep, i'll brainstorm some more in the morning night Kapil
cheers,
Chris
Chris, Out of curiosity, what exactly is a non-blocking MailHost? On Mon, Sep 04, 2000 at 09:31:15AM +0100, Chris Withers wrote:
What we really want is a non-blocking MailHost.
Anyone know how or want to write one?
------------------------------------------------------ Andres Corrada-Emmanuel Email: andres@corrada.com ------------------------------------------------------
From: "Chris Withers" <chrisw@nipltd.com>
I've noticed that sending mail from within Zope the <sendmail> tab or mailhost.send() is very slow (like it adds a few seconds to the time it takes to get a page back from a post).
Why is that? how can I make it faster?
I'd thought about having the actual mail sending done in a different thread/process but I don't know how I'd do that or whether it'd be worth doing.
You could use Xron to schedule sending the email. You could schedule it for later or for "now". Either way the email would be sent asyncronously from the original request. (But check out another email dated today titled "Xron test"). -- Loren
participants (5)
-
andresï¼ corrada.com -
Chris Withers -
Kapil Thangavelu -
Loren Stafford -
Shane Hathaway