Name

email-raw — send raw-formatted e-mail using SendMailProgram

ATTRIBUTES

Attribute Pos. Req. Default Description
interpolate     0 interpolate input?
reparse     1 interpolate output?
hide     0 Hide the tag return value?

DESCRIPTION

This tag simply feeds SendMailProgram with the raw-formatted e-mail data you provide.

This means you also need to provide all the e-mail headers. Header lines must be at the beginning of the line, and the header must have a valid To: field, or the message surely won't be delivered.

Also, as usual, there has to be one empty line between the last header line and beginning of e-mail body.

BEHAVIOR

This tag appears to be affected by, or affects, the following:
Catalog Variables: MV_EMAIL_INTERCEPT
Global Variables: MV_EMAIL_INTERCEPT

EXAMPLES

Example: Simple raw e-mail message

Put the following on a test page:

[email-raw]
From: test@localhost
To: root@localhost
Subject: DEAR FRIEND

THROUGH THE COURTESY OF BUSINESS OPPORTUNITY, I TAKE LIBERTY ANCHORED ON A
STRONG DESIRE TO SOLICIT YOUR ASSISTANCE ON THIS MUTUALLY BENEFICIAL AND
RISKFREE TRANSACTION WHICH I HOPE YOU WILL GIVE YOUR URGENT ATTENTION.

I HAVE DEPOSITED THE SUM OF THIRTY MILLION,FIVE HUNDRED THOUSAND UNITED
STATES DOLLARS(US$30,500,000) WITH A SECURITY COMPANY FOR SAFEKEEPING.
THE FUNDS ARE SECURITY CODED TO PREVENT THEM FROM KNOWING THE ACTUAL
CONTENTS.

MAY I AT THIS POINT EMPHASIZE THE HIGH LEVEL OF CONFIDENTIALLITY WHICH THIS
BUSINESS DEMANDS AND HOPE YOU WILL NOT BETRAY THE TRUST AND CONFIDENCE WHICH
WE REPOSE IN YOU.
[/email-raw]

We hope you will recognize an attempt at humor in the example above, and won't use it as an idea for spamming activities.


NOTES

All outgoing e-mails can be intercepted for development purposes by setting MV_EMAIL_INTERCEPT.

AVAILABILITY

email-raw is available in Interchange versions:

4.6.0-5.9.0 (git-head)

SOURCE

Interchange 5.9.0:

Source: code/UserTag/email_raw.tag
Lines: 73


# Copyright 2002-2007 Interchange Development Group and others
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: email_raw.tag,v 1.8 2007-03-30 23:40:56 pajamian Exp $

UserTag email-raw hasEndTag
UserTag email-raw addAttr
UserTag email-raw Interpolate
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"
  $header_block =~ s/\r?\n([ \t]+)/$1/g;
  my @headers;
  for (split /\r?\n/, $header_block) {
    if (my ($header, $value) = /^(To|Cc|Bcc):\s*(.+)/si) {
      logError(
        "Intercepting outgoing email (%s: %s) and instead sending to '%s'",
        $header, $value, $intercept
      );
      $_ = "$header: $intercept";
      push @headers, "X-Intercepted-$header: $value";
    }
    push @headers, $_;
  }
  $body = join("\n", @headers) . "\n\n" . $body;
}

  SEND: {
my $using = $Vend::Cfg->{SendMailProgram};

if (lc $using eq 'none') {
  $ok = 1;
  last SEND;
} elsif (lc $using eq 'net::smtp') {
  $body =~ s/^(.+?)(?:\r?\n){2}//s;
  my $headers = $1;
  last SEND unless $headers;
  my @head = split(/\r?\n/,$headers);
  $ok = send_mail(\@head,$body);
} else {
  open(Vend::MAIL,"|$using -t") or last SEND;
  print Vend::MAIL $body
    or last SEND;
  close Vend::MAIL
    or last SEND;
  $ok = ($? == 0);
}
  }

  if (!$ok) {
      ::logError("Unable to send mail using $Vend::Cfg->{SendMailProgram}\n" .
          "Message follows:\n\n$body");
  }

  return $opt->{hide} ? '' : $ok;
}
EOR

AUTHORS

Interchange Development Group

SEE ALSO

email(7ic), MV_EMAIL_INTERCEPT(7ic), SendMailProgram(7ic)

DocBook! Interchange!