Web Hosting Talk







View Full Version : CGI sendmail and bulk-email?


Matthew.A
03-05-2001, 07:07 PM
I've got a job that needs to run each night on my server to send out emails, this is going to be anything from 10-5000 e-mails each one different. I'm writing a CGI script for this process at the moment but everytime I add the code in to send the e-mail, the script fails with the message "aborted due to compilation errors" only when I add these lines...
($sendmail already set to $sendmail = "/usr/sbin/sendmail";)
open(MAIL,"|$sendmail -t");
print MAIL "To: $toemail\n";
print MAIL "From: crap@here.com\n";
print MAIL "Subject: $subject\n";
print MAIL "$body\n\n";
close(MAIL);
If I take comment these lines out it all works as expected... any ideas?

Secondly - Is this the best way to do it? Or is it possible for me to create a whole bunch of text files (with hdrs/to/from etc.) in them and some how dump them to the mail server? This I think would be better as the whole process can run, and then 30mins later they can be sent rather that trying to do everything at once. Is this possible? How would I go about it?

TIA (as ever!)

Matthew.A
03-06-2001, 05:30 AM
Well I sorted out the first part of my problem, I forgot to escape the @ sign in the e-mail address "crap\@here.com"!

However I'd still like some advice on the second part...