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.

To create a new field, we must click in the button new field and select the quantity of field

Note: 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

Tutorial: Cloud File Management

Some of the data storage services are ready to securely read and store files and images from your S...

Integration with WhatsApp

To integrate WhatsApp with ScriptCase, we will be using a specific API called Chat-API, it is a...

Tutorial: Blank Application

In this example a Blank application will be created, using for example jquery code to create an acc...

Using the Paypal and Pagseguro API

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

Comment this post