sc_mail_send(SMTP, Usr, Pw, From, To, Subject, Message, Mens_Type, Copies, Copies_Type, Port, Connection_Type, Attachment, SSL)

This macro is used to send emails.

Parameter
Description
SMTP SMTP server name or IP address. (String or Variable that contains the server name)
Usr SMTP username. (String or Variable that contains the username)
Pw SMTP password. (String or Variable that contains the password)
From From email. (String or Variable that contains the email)
To List of the emails that will receive the message, it could be a string or variable that contains one or more emails separated by ";" or one variable that contains one array of emails.
Subject Message subject. (String or Variable that contains the subject)
Message Message body. (String or Variable that contains the message)
Mens_Type Message format: (T) Text or (H) HTML.
Copies List of the emails that will receive the message, it could be a string or variable that contains one or more emails separated by ";" or one variable that contains one array of emails.
Copies_Type Type copies: BCC (Hidden copies) or CCC (Regular copies).
Port The port used by your e-mail server. Use the port 465 for the security type SSL, and the port 587 for the security type TLS or the port 25 for no security. If not informed, Scriptcase will set the default port: 25
Connection_Type Indicating a secure connection. Use S for SSL, T for TLS or N for non-secure connections. If not informed, Scriptcase will set the default value:N.
Attachment Absolute path of the file that will be attached in the email
SSL Optional parameter to add SSL settings. If you need to add more than one setting, use ";" for separate them. Ex: $ssl = 'allow_self_signed=false;verify_peer=false';
Reply_to It is the email address the reply message is sent to, when you want the reply to go to an email address other than the From address.

Note: To use safe connection its required to have the PHP "php_openssl" extension enable.

 

Example 1: Sending e-mail with reply_to parameter

To use the replay_to parameter, you must include all the other parameters before it, just inform them empty.

sc_mail_send('smtp.meuserver.com.br', 'usr', 'pw', 'from@netmake.com.br', 'to@netmake.com.br', 'test sending
of e-mail', 'message', 'H', 'abc@cop.com.br;zxy@cop.com.br', 'CCC', '587', '', 'c:/teste/arq .txt','','reply@netmake.com.br');

Example 2: Using variables and defining the port.

sc_mail_send([glo_smtp], [usuar], [glo_pw], {from}, {to}, {subject}, {message}, 'T', [glo_copias], 'CCC', '419', 'S', {attached});

 

Example 3: No user and password.

The amount of emails sent will be stored at the special variable sc_mail_count.
If any error happens when the Scriptcase try to send the email, the variable sc_mail_ok will receive "false" and the error message will be stored on the variable sc_mail_erro.

sc_mail_send([glo_smtp], '', '', 'from.netmake.com.br', {to}, {subject}, {message}, 'H', '', '', '', '', [glo_att]);

 

Example 4: Email validation with {sc_mail_ok}

sc_mail_send([glo_smtp], '', '', 'from@netmake.com.br', {to}, {subject}, {message}, 'H');

if ({sc_mail_ok}) {

echo "sent {sc_mail_count} e-mail(s) with success!!";

} else {

sc_error_message({sc_mail_erro});

}

 

Example 5: Sending attached files

//Defining macro parameters in variables
$mail_smtp_server   = 'smtp.gmail.com';  // SMTP Server
$mail_smtp_user = 'doc@gmail.com.br'; // SMTP access user
$mail_smtp_pass = 'password'; // Password for the SMTP user entered above
$mail_from = 'doc@gmail.com.br'; // Message origin email
$mail_to = 'doc@gmail.com.br'; // Email of message recipient
$mail_subject = 'Subject'; // Email subject
$mail_message = 'Email body'; // Email body
$mail_format = 'T'; // Email body format: T (Text only) or H (For text and HTML)
$mail_copies = ''; // Parameter that defines the copied emails.
$mail_tp_copies = ''; // Copy type: BCC (For blind copy) or CCC (For normal copy)
$mail_port = '465'; // Sending server port
$mail_tp_connection = 'S'; // Use or not of secure connection: Y (Secure connection) or N (Insecure connection)
$mail_attachments = 'c:/teste/arq.txt' // Directory of the file that will be sent as an attachment //Macro with variables sc_mail_send($mail_smtp_server, $mail_smtp_user, $mail_smtp_pass, $mail_from, $mail_to, $mail_subject, $mail_message, $mail_format, $mail_copies, $mail_tp_copies, $mail_port, $mail_tp_connection, $mail_attachments);

 

Example 6: Sending multiple files as attachments

//Parâmetros do e-mail
$mail_smtp_server   = 'smtp.gmail.com':   // SMTP Server
$mail_smtp_user = 'doc@gmail.com.br'; // SMTP access user
$mail_smtp_pass = 'password'; // Password for the SMTP user entered above
$mail_from = 'doc@gmail.com.br'; // Message origin email
$mail_to = 'doc@gmail.com.br'; // Email of message recipient
$mail_subject = 'Subject'; // Email subject
$mail_message = 'Email body'; // Email body
$mail_format = 'T'; // Email body format: T (Text only) or H (For text and HTML)
$mail_copies = ''; // Parameter that defines the copied emails.
$mail_tp_copies = ''; // Copy type: BCC (For blind copy) or CCC (For normal copy)
$mail_port = '465'; // Sending server port
$mail_tp_connection = 'S'; // Use or not of secure connection: Y (Secure connection) or N (Insecure connection)
// Array of the file that will be sent as an attachment. $mail_attachments = array('C:\Program Files\NetMake\v9-php81\wwwroot\scriptcase\file\img\color.png','C:\Program Files\NetMake\v9-php81\wwwroot\scriptcase\file\img\test.txt'); //Macro with variables sc_mail_send($mail_smtp_server, $mail_smtp_user, $mail_smtp_pass, $mail_from, $mail_to, $mail_subject, $mail_message, $mail_format, $mail_copies, $mail_tp_copies, $mail_port, $mail_tp_connection, $mail_attachments);