Email API with the sc_send_mail_api Macro

1 – Create an application of type Control

2 – We proceed to create the necessary fields for sending an email.

obs: we will use these fields to generate the application.

3 – In the OnValidateSuccess event we proceed to add the following code

function explodeMail($str, $type)
   $arr = explode(‘,’, $str);
   $arr_return = [];
   foreach ($arr as $item) {
    $arr_return[] = array(
                            ‘name’    => ”,
                            ‘type’    => $type,
                            ’email’    => $item
   return $arr_return;

$arr_to = explodeMail({mail_to}, ‘to’);
if ( !empty({to_cc}) ) { $arr_cc = explodeMail({to_cc}, ‘cc’); } else {$arr_cc = array();}
if ( !empty({to_bcc}) ) { $arr_bcc = explodeMail({to_bcc}, ‘bcc’); } else {$arr_bcc = array();}

$arr_merge   = array_merge($arr_to, $arr_cc, $arr_bcc);
$txt_no_tags    = strip_tags({msg});

if ({api_type} == ‘smtp’) {
    // SMTP Settings
    $var_config = get_settings_smtp($txt_no_tags, $arr_merge);    
} elseif ({api_type} == ‘mandrill’) {
    // MANDRILL Settings
    $var_config = get_settings_mandrill($txt_no_tags, $arr_merge);
} elseif ({api_type} == ‘ses’) {
    // AMAZON SES Settings
    $var_config = get_settings_amazon($txt_no_tags, $arr_merge);

//echo “<pre>”;
//echo “</pre>”;



4 – We proceed to create a field called api_type to verify what type of shipment we will use and then perform a manual lookup.

5 – We proceed to create another smtp_protocol field, where a manual lookup is performed for the use of SSL or TLS

6 – Once finished we can load the data in the created fields.

Tutorials in the same category

Using the Paypal and Pagseguro API

1 - We create an application of the grid type 2 - We edit the following fields and create a ...

Send multiple SMS with the sc_send_sms macro

In this example we will be seeing how we can create an application that helps us send multiple mess...

Send SMS with the sc_send_sms macro

Creating a Control application 1 - We create an application of type Control. 2 - Once the...

Using the Mandrill API with macro sc_call_api

In this tutorial we will be showing how to use the sc_call_api macro with the Mandrill API. ...

Comment this post