ePages 6.10 - DE_EPAGES/Mail/API/SMTP.pm

Package DE_EPAGES::Mail::API::SMTP

This package is used to communicate with the SMTP server.

Example
my $Connection = DE_EPAGES::Mail::API::SMTP->new('mail');
$Connection->openConnection;
$Connection->sendDataToSMTP( "This is a test", {
    'FROM'      => 'Sender <mailer@epages.de>',
    'TO'        => ['Recipient <rcpt@epages.de>'],
    'SUBJECT'   => 'Hello'
} );
$Connection->closeConnection;

Functions

closeConnection
existsConnection
new
openConnection
sendDataToSMTP

closeConnection

Closes the existing connection to the SMTP server.

Syntax
$Connection->closeConnection();

existsConnection

Checks for an existing connection to the SMTP server.

Syntax
$IsOpen = $Connection->existsConnection();
Return
$IsOpen (boolean)
1=connection is open, 0=connection is closed

new

Creates a new SMTP connection object. This does not automatically open the connection. Use

Syntax
$Connection = DE_EPAGES::Mail::API::SMTP->new($Server, $Port, $Login, $Password);
$Connection = DE_EPAGES::Mail::API::SMTP->new($Server, $Port);
$Connection = DE_EPAGES::Mail::API::SMTP->new($Server);
Example
my $Connection = DE_EPAGES::Mail::API::SMTP->new('mail');
Input
$Server (string)
SMTP server name
$Port (int)
SMTP server port (optional, default=25)
$Login (string)
SMTP login name (optional)
$Password (string)
SMTP password (optional)
Return
$Connection (object)
SMTP connection object

openConnection

Creates a connection to the SMTP server.

Syntax
$Connection->openConnection();

sendDataToSMTP

Creates the e-mail headers from the options in $hParams and sends the mail to the SMTP server.

Syntax
$Connection->sendDataToSMTP( $MailBody, $hParams );
Example
$Connection->sendDataToSMTP( "This is the text", {
         'HEADER_ENC'=> 'iso-8859-1',
         '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>'
                        ],
         'SUBJECT'   => 'Hello',
        });
Input
$MailBody (string)
the mail content (MIME body)
$hParams (reference to hash)
with following keys:
  • HEADER_ENC - char. encoding of the Header (default:utf-8)(optional) - string
  • FROM - the sender "Phrase <name@host.domain>" - string
  • NOTIFY - read notification to sender 1/0 (optional)- boolean
  • REPLY - the reply address 'Phrase <name@host.domain>' (optional)- string
  • TO - the recipients 'Phrase <name@host.domain>' (optional)- array
  • SkipBadRecipients - 1/0 ignore recipient addresses like
    'name@epa@ges.de' (optional)- boolean
  • CC - the CC recipients 'Phrase <name@host.domain>' (optional)- array
  • BCC - the BCC recipients 'Phrase <name@host.domain>'(optional)- array
  • SUBJECT - the email subject (optional)- string