Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending bulk mail via qmail 1

Status
Not open for further replies.

Muppsy007

Programmer
Apr 4, 2003
98
0
0
NZ
Hi,

We've got a database of around 120 partners that we want to email a personalised letter at once.

I decided to do this using php's mail() command.

Basically, the script gets all the addresses and loops through one at a time and sends a message.

The problem is, when I run it, using my own address for each record, only 20 are sent (exactly 20, every time). After that it if I try again it sends none.

If I try a different mail script somewhere else on the website, it works fine.

If I come back to it a day later, it does the same thing, 20, then nothing, which leads me to think that it may have something to do with qmail's queue.

Does this sound familiar to anyone at all?

It's running in a FreeBSD 4.8 server.

Thanks
Aaron
 
I think what you're encountering is that there are only 20 available qmail-smtpd listeners available as configured in your /var/qmail/supervise/qmail/smtpd/run file. Thus when PHP runs very fast and occupies all 20 immediately, the 21st PHP request will bomb your script. This is happening because you're using the mail() command which I believe uses an SMTP session instead of calling qmail-inject directly.

My suggestion is to include a "sleep" command in your script to call the "mail()" function with a 1 second delay between every 3-4 requests.

Alternatively you could UP the number of available qmail-smtpd's in your 'run' file, BUT BE WARNED that this is a global change that affects the number of connections you can receive from the outside world and can significantly impact system performance under heavy load or attack.

D.E.R. Management - IT Project Management Consulting
 
Champion thedaver,

I did think along similar lines and tried a loop with a sleep(2) every 5 calls to mail().

The script kept on crashing but I do beleive this is a logic error on my part in the script.

Will keep at it using that method, thanks for the confirmation.

Will post the outcome
 
And one thing I did not mention was that you could write a lower-level script to use qmail-inject directly which should not suffer from a hard cap set by tcpserver for smtpd

D.E.R. Management - IT Project Management Consulting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top