|
This macro allows dynamic sending of embedded emails with the Mandrill and Amazon SES APIs. It is also possible to send e-mail using the SMTP protocol.
This macro uses the same mandrill parameters to send e-mail, regardless of the Gateway (Changer, Amazon SES or SMTP) selected. click here and see the list of parameters that can be used.
This macro contains a single parameter "$arr_settings", which receives an array with the email sending information.
For more information on the parameters the mandirll click here
.
Parameter
|
Description |
| $arr_settings |
Array with information for use of APIs. |
Array indices
|
Description |
| profile |
Name of some API already configured in "Tools> API", as can be seen in Example 1. When informing a profile, the settings index should not be informed. |
| settings |
E-mail sending server settings. The information must conform to the API used. Note: When informing the settings, the Profile index is disregarded. |
| message |
Message that will be sent by email. Subject, body, to, etc. |
Example 1: Sending e-mail using a pre-configured Profile in "Tools> API".
if({api_type} == 'smtp' ){
$var_config = array(
'profile' => 'yahoo_example',
'message' => [
'html' => {email_body},
'text' => '',
'to' => $arr_merge,
'subject' => {subject}
]
);
}
sc_send_mail_api($var_config);
Example 2: Sending e-mail via SMTP
$smtp_server = "smtp.mail.yahoo.com";
$smtp_port = "465";
$smtp_user = "scriptcase.export";
$smtp_password = "scriptcase.export";
$from_email = "scriptcase.export@yahoo.com";
$from_name = "Scriptcase Export";
if ( {api_type} == 'smtp' ){
$var_config = array(
'profile' => '',
'settings' => [
'gateway' => 'smtp',
'smtp_server' => $smtp_server,
'smtp_port' => $smtp_port,
'smtp_user' => $smtp_user,
'smtp_password' => $smtp_password,
'from_email' => $from_email,
'from_name' => $from_name
],
'message' => [
'html' => {email_body},
'text' => '',
'to' => $arr_merge,
'subject' => {subject}
]
);
}
sc_send_mail_api($var_config);
Example 3: Sending email using Mandrill API
if({api_type} == 'mandrill' ){
$var_config = array(
'settings' => [
'gateway' => 'mandrill',
'api_key' => {api_key},
'from_email' => {from_email},
'from_name' => {from_name}
],
'message' => [
'html' => {email_body},
'text' => '',
'to' => array($arr_merge),
'subject' => {subject}
]
);
}
sc_send_mail_api($var_config);
Example 4: Sending email using Amazon SES API
if({api_type} == 'ses' ){
$var_config = array(
'settings' => [
'gateway' => 'ses',
'region' => {ses_region},
'api_key' => {api_key},
'api_secret' => {ses_secret},
'from_email' => {from_email}
],
'message' => [
'html' => {email_body},
'text' => '',
'to' => array($arr_merge),
'subject' => {subject}
]
);
}
sc_send_mail_api($var_config);
|