ePages 7.38.0 - 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

className
content
dbPackage
from
getMail
getPageType
joinMailAddress
replaceTLEs
send
sendMail
to

className

Returns the class name, used for DAL access.

Syntax
$ClassName = $MailType->className;
Return
$ClassName (String)
class name

content

The TLE placeholders in the mail template content are replaced by the variables given in $hVars.

Syntax
$Content = $MailType->content( $Object, $Content, $hRegionalParams, $hVars );
Example
$Content = $MailType->content( $System, undef, $hRegionalParams, $hVars );
Input
$Object (object)
send mail for object
$Content (string)
user-specified content (overrides template)
$hRegionalParams (ref.hash)
regional options
  • Locale
  • Language
$hVars (ref.hash)
TLE variables hash
$SkipAdditionalAttributes (boolean (optional))
include AdditionalText and Header attributes
Return
$Content (string)
content

dbPackage

Returns the database package, used for DAL access.

Syntax
$DbPackage = $MailType->dbPackage;
Return
$DbPackage (String)
database package name

from

returns FROM address string of the mail

Syntax
$FROM = $MailType->from;
$FROM = $MailType->from( $FROM );
Example
$FROM = $MailType->from;
Input
$FROM (string)
mail 'from' field (optional)
Return
$FROM (string)
mail 'from' field

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

getPageType

Returns the page type related to the current mail type.

Syntax
$PageType = $MailType->getPageType();
Input
$Object (object)
send mail for object
Return
$PageType (PageType object)
PageType

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

replaceTLEs

The TLE placeholders in the string are replaced by the variables given in $hVars.

Syntax
$String = $MailType->replaceTLEs( $Object, $String, $hRegionalParams, $hVars );
Example
$String = $MailType->replaceTLEs( $System, 'Hello #FirstName', $hRegionalParams, $hVars );
Input
$Object (object)
send mail for object
$String (string)
template string with TLEs
$hRegionalParams (ref.hash)
regional options
  • Locale
  • Language
$hVars (ref.hash)
TLE variables hash
Return
$String (string)
string with replaced TLE variables

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

sendMail

Sends the e-mail using the default SMTP connection that is configured in the current database.

Syntax
$MailType->sendMail( $Mail );
Input
$Mail (object)
e-mail object, see DE_EPAGES::Mail::API::Mail

to

returns TO address string of the mail

Syntax
$TO = $MailType->to;
$TO = $MailType->to( $TO );
Example
$TO = $MailType->to;
Input
$TO (string)
mail 'to' field (optional)
Return
$TO (string)
mail 'to' field