ePages 6.10 - DE_EPAGES/MailType/API/Object/MailType.pm

Package DE_EPAGES::MailType::API::Object::MailType

object interface for MailType (aka e-mail events).

Base
DE_EPAGES::Object::API::Object::Object
Example
#send order confirmation mail to customer
my $MailType = $Order->getSite()->child('MailTypes')->child('CustomerOrderConfirmation');

# create and send mail
my %MailParams = (
    'HTMLAllowed' => $Order->get('Customer')->get('IsHtmlEMailAllowed'),
);
my $Email = $Order->get('BillingAddress')->get('EMail');
$MailParams{'TO'} = $Email if defined $Email;

my %Vars = ();
my $Container = $Order->get('LineItemContainer');
my %RegionalParams = (
    Locale      => $Container->get('LocaleID'),
    Language    => GetCodeByLanguageID($Container->get('LanguageID')),
);
$MailType->send( $Order, \%MailParams, \%RegionalParams, \%Vars );

Functions

getMail
getMailParams
joinMailAddress
send

getMail

Creates an e-mail object for the mail type.

Syntax
$Mail = $MailType->getMail($Object, $hParams, $hRegionalParams, $hVars);
Input
$Object (object)
send mail for object
$hMailParams (ref.hash optional)
e-mail options
  • FROM - FROM (optional) - string
  • REPLY - REPLY (optional) - string
  • TO - TO (optional) - string
  • CC - CC (optional) - string
  • BCC - BCC (optional) - string
  • HTMLAllowed - send mail as HTML (default: 0=plain text) - boolean
  • Subject - subject of mail (optional) - string
  • Content - content of mail (optional) - string
  • Attachments - mail attachments (optional) - ref.array.hash
  • SkipBadRecipients - 1/0 ignore recipient addresses like 'name@epa@ges.de' (default: 1)- boolean
$hRegionalParams (ref.hash)
regional options
  • Locale - locale id, e.g. 'en_GB' - strin
  • Language - language id, e.g. 'en' - string
$hVars (ref.hash)
TLE variables hash
Return
$Mail (object)
mail object (instance of DE_EPAGES::Mail::API::Mail)
Hook
MailTypeGetMail
hook parameter keys :
  • Object - mail processed for object - object
  • MailType - mail type - object
  • Mail - mail - object

getMailParams

Appends default mail type parameters to current mail parameter.

Syntax
$hMailParams = $MailType->getMailParams($Object, $hParams, $hRegionalParams, $hVars);
Input
$Object (object)
context of the e-mail, for example a shop or an order
$hParams (ref.hash optional)
e-mail options
  • FROM - FROM (optional) - string
  • REPLY - REPLY (optional) - string
  • TO - TO (optional) - string
  • CC - CC (optional) - string
  • BCC - BCC (optional) - string
  • HTMLAllowed - send mail as HTML (optional, default: 0=plain text) - boolean
  • Subject - subject of mail (optional) - string
  • Content - content of mail (optional) - string
$hRegionalParams (ref.hash)
regional options
  • Locale
  • Language
$hVars (ref.hash)
TLE variables hash
Return
$hMailParams (ref.hash)
e-mail options
  • FROM - FROM - string
  • REPLY - REPLY - string
  • TO - TO - string
  • CC - CC - string
  • BCC - BCC - string
  • HTMLAllowed - send mail as HTML - boolean
  • Subject - subject of mail - string
  • Content - content of mail - string
  • Attachments - attachments of mail - ref.array.hash

joinMailAddress

joins the name and email to an email-address

Syntax
$EMailAddress = $MailType->joinMailAddress($Name, $EMail);
Example
$EMailAddress = $MailType->joinMailAddress("Max Mustermann", "m.mustermann@epages.de");
$EMailAddress eq '"Max Mustermann" <m.mustermann@epages.de>'
Input
$Name (string)
name of email user
$EMail (string)
email
Return
$EMailAddress (string)
joined name and email

send

Sends an e-mail object using the current mail type if the MailType is active or not. The TLE placeholders in the mail templates for Content, Subject and Signature are replaced by the variables given in $hVars. Triggers the hook "MailTypeSend" before actually building the mail object and sendinf the mail. Hook functions can prevent the mail from beeing sent by setting the hook parameter "SendMail" to 0. In this case the return value will be 0.

Syntax
$Sent = $MailType->send($Object, $hMailParams, $hRegionalParams, $hVars );
Example
$MailType->send( $User, {
        HTMLAllowed => 1,
        TO => $User->get('EMail'),
    }, {
        Language => 'de',
        Locale => 'de_DE'
    }, { } );
Input
$Object (object)
send mail for object
$hMailParams (ref.hash)
e-mail options, see getMail
$hRegionalParams (ref.hash)
regional options, see getMail
$hVars (ref.hash)
TLE variables hash
Return
$Sent (boolean)
true if the mail was actually sent