Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Makefile: added support for howtos
- README: replaced unintended tabs with spaces - TODO: items - docbook/docbookxi.dtd: ICTBALL renamed to ICDL - docbook/xmldocs.css: quite a lot of tuning - guides/iccattut.xml: little wording and XML fixes - refs/*/example*: replacing tabs with spaces (XML wants that) - other...
- Loading branch information
Showing
10 changed files
with
266 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<chapter id="CustomSendmailRoutine"> | ||
|
||
<chapterinfo> | ||
<title>Custom Sendmail Routine</title> | ||
<titleabbrev>customsendmail</titleabbrev> | ||
|
||
<keywordset> | ||
<keyword>custom</keyword> | ||
<keyword>send</keyword> | ||
<keyword>mail</keyword> | ||
<keyword>routine</keyword> | ||
<keyword>delay</keyword> | ||
</keywordset> | ||
|
||
<authorgroup> | ||
<author> | ||
<firstname>Mike</firstname> | ||
<surname>Heins</surname> | ||
<affiliation> | ||
<email>mheins@perusion.net</email> | ||
</affiliation> | ||
</author> | ||
</authorgroup> | ||
|
||
|
||
</chapterinfo> | ||
|
||
<sect1 id='introduction'> | ||
<title>Introduction</title> | ||
<para> | ||
Someone <ulink url="http://www.icdevgroup.org/pipermail/interchange-users/2004-July/039811.html">was wondering</ulink> how to optimize the order processing on a busy site. It was observed that about once in every ten times, the <filename>etc/mail_receipt</filename> takes a few <emphasis>extra</emphasis> seconds before it's mailed out. | ||
</para> | ||
<para> | ||
The delay occured because in the code used, the <option>SendMailProgram</option> ran in foreground so the ordering process "stalled" for a few seconds (or at least that's how the average customer saw it). The critical section was reduced to: | ||
</para> | ||
|
||
<screen> | ||
<![CDATA[ | ||
[email to="[scratch to_email], __MAIL_RECEIPT_CC__" | ||
subject="__COMPANY__ Order #[value mv_order_number]: [scratch subject_end]" | ||
from=|"__COMPANY__ Order Confirmation" <orders at company.com>| ] | ||
... email contents ... | ||
[/email] | ||
]]> | ||
</screen> | ||
</sect1> | ||
|
||
<sect1 id='solution'> | ||
<title>Solution</title> | ||
<para> | ||
To eliminate this "delay", you could use a custom script that accepts the message on standard input (STDIN), and then calls <application>Sendmail</application> in the background. | ||
</para> <para> | ||
Save the script with the following contents to <filename>/usr/local/bin/sendmail-bg</filename>: | ||
</para> | ||
|
||
<programlisting> | ||
<![CDATA[ | ||
#!/usr/bin/perl | ||
#use strict; | ||
#use warnings; | ||
use File::Temp; | ||
my $basedir = '/tmp/sendmail'; | ||
my $sendmail = '/usr/sbin/sendmail -t'; | ||
umask 2; | ||
mkdir $basedir unless -d $basedir; | ||
my $tmp = File::Temp->new( DIR => $basedir ); | ||
my $tmpnam = $tmp->filename; | ||
open OUT, "> $tmpnam" or die "Cannot create $tmpnam: $!\n"; | ||
my $cmdline = join " ", $sendmail, '<', $tmpnam, '&'; | ||
while(<>) { print OUT $_; } | ||
close OUT; | ||
system($cmdline); | ||
if($?) { die "Failed to fork sendmail: $!\n" } | ||
]]> | ||
</programlisting> | ||
|
||
<para> | ||
And of course, don't forget to add/modify the <option>SendMailProgram</option> directive: | ||
</para> | ||
|
||
<programlisting> | ||
SendMailProgram /usr/local/bin/sendmail-bg | ||
</programlisting> | ||
|
||
</sect1> | ||
|
||
</chapter> | ||
|
Oops, something went wrong.