Mail::File - mail module which writes to a flat file.
use Mail::File; my $mail = Mail::File->new(template => 'mailXXXX.tmp'); $mail->From('firstname.lastname@example.org'); $mail->To('email@example.com'); $mail->Cc('Them <firstname.lastname@example.org>'); $mail->Bcc('Us <email@example.com>; firstname.lastname@example.org'); $mail->Subject('Blah Blah Blah'); $mail->Body('Yadda Yadda Yadda'); $mail->XHeader('X-Header' => 'Blah Blah Blah'); $mail->send; # Or use a hash my %hash = ( From => 'email@example.com', To => 'firstname.lastname@example.org', Cc => 'Them <email@example.com>', Bcc => 'Us <firstname.lastname@example.org>, email@example.com', Subject => 'Blah Blah Blah', Body => 'Yadda Yadda Yadda', 'X-Header' => 'Blah Blah Blah', template => 'mailXXXX.tmp' ); my $mail = Mail::File->new(%hash); $mail->send;
This module was written to overcome the problem of sending mail messages, where there is no mail application available.
The aim of the module is to write messages to a text file, that will format the contents to include all the key elements of the message, such that the file can be transported to another machine, which is then capable of sending mail messages.
Notes that the filename template defaults to 'mail-XXXXXX.eml'.
Create a new mailer object. Returns the object on success or undef on failure.
All the following can be passed as part of an anonymous hash:
From To Cc Bcc Subject Body template
The template entry is optional, and is only supplied when you call the constructor. The format of the string to template follows the format as for File::Temp. However, a suffix is automatically extracted. An example template would be:
Where the temnplate to File::Temp would be 'mail-XXXX' and the suffix would be '.tmp'.
The default template, if none is supplied is:
The following accessor methods are available:
From To Cc Bcc Subject Body
All functions can be called to return the current value of the associated object variable, or be called with a parameter to set a new value for the object variable.
Adds a header in the style of 'X-Header' to the headers of the message. Returns undef if header cannot be added.
Sends the message. Returns the filename on success, 0 on failure.
Really just writes to a file.
May add the ability to handle MIME content headers and attachments.
There are no known bugs at the time of this release. However, if you spot a bug or are experiencing difficulties that are not explained within the POD documentation, please submit a bug to the RT system (see link below). However, it would help greatly if you are able to pinpoint problems or even supply a patch.
Fixes are dependent upon their severity and my availability. Should a fix not be forthcoming, please feel free to (politely) remind me by sending an email to firstname.lastname@example.org .
Barbie, <email@example.com> for Miss Barbell Productions, <http://www.missbarbell.co.uk>
Copyright (C) 2003-2014 Barbie for Miss Barbell Productions. This distribution is free software; you can redistribute it and/or modify it under the Artistic Licence v2.