MV_EMAIL_INTERCEPT — intercept all outgoing email and redirect it to the specified address
If defined, the variable causes all outgoing e-mail to be intercepted, and sent to a specified address or comma-separated addresses.
This feature is intended to allow developers to write and test functions that send e-mail, without worrying about accidentally sending mail to end users.
A header in the form of X-Intercepted-To:
is inserted
in the message to show the original destination. At the same time,
the interception is also noted in the catalog error log file.
Example: Setting MV_EMAIL_INTERCEPT to "root@mydomain.local"
Set the following in interchange.cfg
or catalog.cfg
:
Variable MV_EMAIL_INTERCEPT root@mydomain.local
Note that this only works for Interchange's built-in e-mail sending routines. If you use other methods to send e-mail, for example by directly running sendmail or talking to an SMTP server you'll have to add implement support yourself.
Be aware that this setting can mask certain programming errors. For
example, trying to send an e-mail without a
To:
address would normally result
in an error. With email interception, however, a valid
To:
address would be used, and seemingly work as
expected. Before switching off the interception, the only
way to know whether you did everything right is to check the
X-Intercepted-To:
header and verify its correctness. Probably even easier, you should
just monitor error log files as the original e-mail destination is
reported there as well.
Interchange 5.9.0:
Source: code/UserTag/email_raw.tag
Line 23 (context shows lines 13-27)
UserTag email-raw Version $Revision: 1.8 $ UserTag email-raw Routine <<EOR sub { my($opt, $body) = @_; my($ok); $body =~ s/^\s+//; # If configured, intercept all outgoing email and re-route if ( my $intercept = $::Variable->{MV_EMAIL_INTERCEPT} || $Global::Variable->{MV_EMAIL_INTERCEPT} ) { $body =~ s/\A(.*?)\r?\n\r?\n//s; my $header_block = $1; # unfold valid RFC 2822 "2.2.3. Long Header Fields"
Source: lib/Vend/Util.pm
Line 2147 (context shows lines 2137-2151 in send_mail():2112)
} elsif($_) { push @extra_headers, $_; } } } # If configured, intercept all outgoing email and re-route if ( my $intercept = $::Variable->{MV_EMAIL_INTERCEPT} || $Global::Variable->{MV_EMAIL_INTERCEPT} ) { my @info_headers; $to = "To: $to"; for ($to, @extra_headers) {
Source: lib/Vend/Email.pm
Line 336 (context shows lines 326-340 in tag_mime_lite_email():91)
::logError("Header injection attempted in tag_mime_lite_email: %s", $1); return; }; } # # Support e-mail interception (re-writing to/cc/bcc to specified # address(es)). # $intercept ||= $::Variable->{MV_EMAIL_INTERCEPT} || $Global::Variable->{MV_EMAIL_INTERCEPT}; if ( $intercept && $Have_MIME_Lite) { for my $field (qw/to cc bcc/) { if ( $opt->{$field} ) {
Source: lib/Vend/Email.pm
Line 596 (context shows lines 586-600 in send_mail_legacy():561)
} elsif($_) { push @extra_headers, $_; } } } # If configured, intercept all outgoing email and re-route if ( my $intercept = $::Variable->{MV_EMAIL_INTERCEPT} || $Global::Variable->{MV_EMAIL_INTERCEPT} ) { my @info_headers; $to = "To: $to"; for ($to, @extra_headers) {