Package DE_EPAGES::Mail::API::Mail
This package is used for processing e-mails. It simplifies creation of HTML mails and mails with attachments.
Example |
my $Connection = DE_EPAGES::Mail::API::SMTP->new( 'mail', 25 ); $Connection->openConnection; my $Mail = DE_EPAGES::Mail::API::Mail->new( { 'FROM' => 'Mailer <sender@domain.com>', 'TO' => ['Recipient1@provider1.com','Name <Recipient2@provider2.com>', ], 'SUBJECT' => 'Test Subject' } ); $Mail->addText({'content' => 'This is Plain Text'}); $Mail->send( $Connection ); $Connection->closeConnection; |
Functions
addAttachment
Adds attachments to the mail.
Syntax |
$Mail->addAttachment( $ahParams ); |
Example |
my $hFile = { 'filename' => '/tmp/Setup.exe', 'type' => 'Application/Octet-stream', }; $Mail->addAttachment( [ $hFile ] ); |
Input |
|
addHTML
Adds an HTML element to the mail.
Syntax |
$Mail->addHTML( $hParams ); |
Example |
$Mail->addHTML({ 'content' => '<body>content</body>', 'encoding' => 'quoted-printable', 'type' => 'text/html', 'type.charset' => 'utf-8', 'html2plain' => 1, 'alttext' => '', 'altencoding' => 'quoted-printable', 'alt.type.charset'=> 'utf-8', }); |
Input |
|
addHTMLAttachment
Adds inline attachments (images, style sheets etc.) to an HTML e-mail.
Syntax |
$Mail->addHTMLAttachment( $ahParams ); |
Example |
my $hStyle = { 'filename' => '/tmp/style.css', 'includeid' => '__reference_id_style_', 'type' => 'text/css', }; my $hImage = { 'filename' => '/tmp/image.jpg', 'includeid' => '__reference_id_image_', 'type' => 'image/jpg', }; $Mail->addHTMLAttachment( [ $hStyle, $hImage ] ); |
Input |
|
addText
Adds a text element to the mail.
Syntax |
$Mail->addText( $hParams ); $Mail->addText({ 'content' => 'Das ist Plain Text', 'encoding' => 'quoted-printable', 'type' => 'text/plain', 'type.charset'=> 'utf-8', }); |
Input |
|
convertHtml2Plain
Creates plain text from HTML.
Syntax |
my $Plain = $Mail->convertHtml2Plain($HTML); |
Input |
|
Return |
|
createMail
Creates the MIME body of the e-mail from the previously added text and attachment elements.
Syntax |
$MailBody = $Mail->createMail(); |
Example |
$Connection->sendDataToSMTP( $Mail->createMail(), $Mail->getHeader() ); |
Return |
|
getHeader
Returns the parameters for the e-mail header.
Syntax |
$hParams = $Mail->getHeader(); |
Return |
|
new
Creates a new object of DE_EPAGES::Mail::API::Mail with header parameters.
Syntax |
$Mail = DE_EPAGES::Mail::API::Mail->new($hParams); my $Mail = DE_EPAGES::Mail::API::Mail->new( { 'HEADER_ENC' => 'iso-8859-1' 'SUBJECT' => 'the Subject' 'FROM' => 'Sender <mailer@epages.de>', 'NOTIFY' => 1, 'REPLY' => 'Replyer <replyaddress@epages.de>', 'SkipBadRecipients' => 1, 'TO' => ['Recipient <rcpt@epages.de>', 'Recipient1 <rcpt1@epages.de>' ], 'CC' => ['CC1 <ccrcpt1@epages.de>', 'CC2 <ccrcpt2@epages.de>' ], 'BCC' => ['BCC1 <bccrcpt1@epages.de>', 'BCC2 <bccrcpt2@epages.de>' ] }); |
Input |
|
Return |
|
send
Sends the mail to the given SMTP Server Connection.
Syntax |
$Mail->send($Connection); |
Input |
|