Skip to content

mail_send ​

php
number mail_send ( string $email, array $params, [[string $html=''], [string $txt='']] )

Sends a message to $email. Returns the mailing ID on success. When not using an existing newsletter, provide the message content as the final two arguments.

Pass the mailing settings in $params. The available parameters are:

ParameterTypeDescription
campaignnumber|stringname or ID of the campaign to assign the mailing to
newsletternumberID of an existing newsletter in SARE (Mailing > Ready tab, first table column)
newsletter_dirstringselected newsletter directory
subjectstringSubject field of the mailing. Empty by default
encodingstringnewsletter encoding. Must be supported by SARE (e.g. UTF-8, ISO-8859-2). Defaults to UTF-8
fromstringFrom (sender) field of the mailing. Must follow this format: "Sender name" <przykladowy@email>  The sender name must be enclosed in double quotes (not single quotes) and separated from the email address by whitespace, such as a space. If omitting the sender name, omit the quotes as well. The email address must be enclosed in < and >. If from is missing from the parameter array or has an invalid format, the mailing uses the default From value configured in SARE preferences.
replytostringReply-To field of the mailing. Must be a syntactically valid email address. Not set by default
use_namebooleanwhether to use the Name field as the recipient name alongside the address in the To field. If use_name is omitted from the parameter array, the “Use the Name field as the recipient” setting in SARE preferences is used.
formatstringmessage format. Defaults to txt,html. Set to txt to send only the plain-text part
format_txtstringmessage format for recipients marked as accepting plain-text messages only. Defaults to txt. Set to html,txt to send both the HTML and plain-text parts;
trace_openingsbooleanwhether to track opens. Defaults to true
trace_clicksbooleanwhether to track link clicks. Defaults to true
trace_txt_clicksbooleanwhether to track link clicks in the plain-text message. Defaults to true
attachmentsarrayarray of email attachments. Each attachment is a two-element array containing the file name and Base64-encoded content.

Example:

$zal = array(); $zal[0] = "nazwa_pliku.txt"; $zal[1] = base64_encode('content of file nazwa_pliku.txt'); $zal2 = array(); $zal2[0] = "nazwa_pliku2.txt"; $zal2[1] = base64_encode('content of file nazwa_pliku2.txt'); $parametry["attachments"] = array($zal, $zal2);

Example:

php
$html = 'Test HTML';
$txt = 'Test TXT';

$zal = array();
$zal[0] = "nazwa_pliku.txt";
$zal[1] = base64_encode('content of file nazwa_pliku.txt');

$parametry = array();
$parametry["subject"] = "Subject";
$parametry["from"] = '"Jan Kowalski" ';
$parametry["attachments"] = array($zal);
$ret = mail_send('odbiorca@maila', $parametry, $html, $txt);

Another example:

php
$parametry = array();
$parametry["subject"] = "Subject";
$parametry["from"] = '"Jan Kowalski" ';
$parametry["newsletter"] = 7;
$ret = mail_send('odbiorca@maila', $parametry);