[ic] email tag for ship_notice CHANGED:[if value email_copy ...] on ship_notice

Stefan Hornburg Racke interchange-users@interchange.redhat.com
Fri May 10 05:23:01 2002


"Aaron Hazelton" <aaronmail@hazenet.net> writes:

> > > Hi all,
> > > 
> > > I have altered the way the "email_copy" field of the userdb table is
> > > used and changed the "mail_receipt" so that my users will have the
> > > option of choosing: no email, plain text, or html.  That was easy.
> > > 
> > > But, now I would also like to make this option carry through for the
> > > shipping notice.  Here's where im having trouble.  I open up the
> > > "order_status.html" admin page and get smacked with a bunch 
> > of perl.  I
> > > found the [email-raw] tag which includes the ship_notice.  
> > > 
> > > First of all, can you do html emails in the [email-raw] tag?  The
> > > usertag doesn't say anything about an 'extra' that you can 
> > call out like
> > > with [email]...
> > > 
> > > I tried putting in [if] statements into the ship_notice 
> > pointing to the
> > > email_copy field but that did not work... All the perl code 
> > outputs to
> > > the error log.  I also tried removing the email-raw tag and 
> > using the
> > > [email] inside the ship_notice but to no avail either.
> > > 
> > > It looks like the perl in this page uses the email_copy field to
> > > generate the "wants_copy" variable, so im not sure if maybe 
> > that's where
> > > it needs some work to do this...?
> > > 
> > > Can someone point me in the right direction?
> > 
> > You _can_ do HTML emails with email-raw AFAIK. Alternatively you can
> > checkout my email_mime.tag posted to this list. I think that would
> > avoid headaches about to format the email stuff.
> > 
> 
> Sure can, I got that to work. Thanks Racke!  BTW, I searched the
> archives and didn't see any email_mime.tag?!?

UserTag email_mime Order to subject reply from extra type path btype
UserTag email_mime hasEndTag
UserTag email_mime Interpolate
UserTag email_mime Routine <<EOR
sub {
    require MIME::Lite;

    my($to, $subject, $reply, $from, $extra, $type, $path, $btype, $body) = @_;
    my($ok, @types, @paths);
    my($msg);

    $subject = '<no subject>' unless defined $subject && $subject;

    $reply = '' unless defined $reply;
    $reply = "Reply-to: $reply\n" if $reply;
	if (! $from) {
		$from = $Vend::Cfg->{MailOrderTo};
		$from =~ s/,.*//;
	}

	$extra =~ s/\s*$/\n/ if $extra;
    $ok = 0;

    $msg = MIME::Lite -> new (From => $from, To => $to, Subject => $subject,
                              Type => ($btype || 'TEXT'), Data => $body);

	if (ref $type eq 'ARRAY') {
		@types = @{$type};
	} else {
		@types = $type;
	}

	if (ref $path eq 'ARRAY') {
		@paths = @{$path};
	} else {
		@paths = $path;
	}

	for (my $i = 0; $i < @types; $i++) {
		$msg -> attach (Type => $types[$i], Path => $paths[$i]);
	}

    $ok = $msg -> send;

    if (!$ok) {
        logError("Unable to send mail using $Vend::Cfg->{'SendMailProgram'}\n" .
            "To '$to'\n" .
            "From '$from'\n" .
            "With extra headers '$extra'\n" .
            "With reply-to '$reply'\n" .
            "With subject '$subject'\n" .
            "And body:\n$body");
    }
    $ok;
}
EOR

Ciao
        Racke

-- 
Think of it !

For projects and other business stuff please refer to COBOLT NetServices
(URL: http://www.cobolt.net; Email: info@cobolt.net; Phone: 0041-1-3884400)