[Raw Msg Headers][Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: queueing multiple messages



> excuse me if this is a beginners question:
> 
> I'm trying to queue many many messages from within PERL.
> 
> For each message, I open a pipe to the /usr/lib/sendmail, and send 
> all the parameters.  Simple, but not fast enough.  Too many 
> opens/closes!

	Hmm.. You mean too many fork()s..

> Is there some way to send multiple messages down open pipe to 
> /usr/lib/sendmail?   if so, how do I end one message and start 
> another?  
> 
> if not, is it possible to write files directly into the outgoing 
> queue?

	Yes.  We do so at University of Turku (and someday possibly
	also at Telecom Finland) where we send modem usage bills to
	users in electronic mail.

	Basically:

	1) Open a temporary file as  $POSTOFFICE/public/billpost.$$

	2) fstat()/stat() it to find out its i-node number (needed
	   latter)

	3) Write transport envelope information:
	   (Stars there note OPTIONAL fields, and work well only at 2.99.41+)
		from sender@address
		*bodytype 8BITMIME
		*notaryret HDRS
		*envid SomeUniqueXTEXTstring
	   ||	*todsn ORCPT=rfc822;recipient@address NOTIFY=XXXX
	   ||	to recipient@address
		env-end
	   There the two lines prefixed with "||" are to be repeated for each
	   recipient.  The ORCPT parameter string must be XTEXT string, see
	   the RFC 1891.  See also legal NOTIFY values from that same RFC.

	4) Continue with RFC-822 headers, e.g.:
		From: <sender@address>
		To: <recipient@address>
		Subject: xxxxxx
		MIME-Version: 1.0
		Content-Type: text/plain; charset=XXXX
		Content-Transfer-Encoding: 8BIT

	5) continue then with a bare newline, and the actual message body
	6) close the file -- no errors ?
	7) If no errors at 6 (file written successfully), do following:

		rename("$POSTOFFICE/public/billpost.$$",
		       "$POSTOFFICE/router/$inode")

	That is the life-cycle of the message submission.



	The 1 can be done with -lzmailer by means of:
		fp = mail_open(MSG_RFC822);
	and 6+2+7 are:
		mail_close(fp);
	of if writing failed (including the last flush):
		mail_abort(fp);
	See "man 3 zmailer" about this interface.

> thanks for any info!
> 
> ______________________________________________________________________
>       Ryan Scott - rscott@netcreations.com - 718 522 1531     
>           - Reinventing Direct Marketing on the Net -
>        NetCreations, Inc - http://www.netcreations.com
>                 - Targeted Voluntary Email -
> PostMaster Direct Response - http://www.netcreations.com/postdirect/
>              *be sure to quote me in your reply*

	I do understand Andrew Kokarev's concerns, "Direct Marketing"
	has gotten really bad name due to Stanford Wallace..
	(if I got that guy's name right..)

	However there are a lot of perfectly valid uses for ability
	to send a lot of email easily -- and you wanted to know it
	too, didn't you ?


/Matti Aarnio <mea@nic.funet.fi>