Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

embedding line in mail header

by perlknight (Pilgrim)
on Apr 30, 2006 at 05:07 UTC ( [id://546553]=perlquestion: print w/replies, xml ) Need Help??

perlknight has asked for the wisdom of the Perl Monks concerning the following question:

all, I have several servers which runs batch jobs. These batch jobs sends out email when completed. I have no issue telling which email comes from which server. However, I sometimes have a hard time tracking down which script it comes from. I am wondering if it is possible to embed the name of the script in the mail header without causing problem with email. Any idea how?

2006-05-01 Retitled by planetscape, as per Monastery guidelines
Original title: 'embeding line in mail header'

Replies are listed 'Best First'.
Re: embedding line in mail header
by Zaxo (Archbishop) on Apr 30, 2006 at 05:33 UTC

    You can devise your own header in the "X-mumble" space, or else put it in Comments. Call it, say, X-SourceScript, and fill it in with $0 when you set up headers for the mail.

    my $msg = MIME::Lite->new( From =>'me@myhost.com', To =>'you@yourhost.com', Cc =>'some@other.com, some@more.com', Subject => $title, X-SourceScript => $0, Data => $message );

    The MIME::Lite pod has more about other forms of custom headers.

    After Compline,
    Zaxo

Re: embedding line in mail header
by eXile (Priest) on Apr 30, 2006 at 05:19 UTC
    It is a custom (not sure whether/where it is documented), to start custom headers with X-. Email servers and clients don't touch these X-headers. You could add your scriptname like:
    Subject: testmail
    To: test@test.com
    X-Scriptname: /usr/local/bin/myscript.pl
    
    PS: oh, the joy I had adding X-wing or X-mas headers to email ...

    PS2: X-headers are actually documented in RFC822 (http://www.faqs.org/rfcs/rfc822.html)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://546553]
Approved by Zaxo
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (1)
As of 2024-04-25 04:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found