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:
| Parameter | Type | Description |
| campaign | number|string | name or ID of the campaign to assign the mailing to |
| newsletter | number | ID of an existing newsletter in SARE (Mailing > Ready tab, first table column) |
| newsletter_dir | string | selected newsletter directory |
| subject | string | Subject field of the mailing. Empty by default |
| encoding | string | newsletter encoding. Must be supported by SARE (e.g. UTF-8, ISO-8859-2). Defaults to UTF-8 |
| from | string | From (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. |
| replyto | string | Reply-To field of the mailing. Must be a syntactically valid email address. Not set by default |
| use_name | boolean | whether 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. |
| format | string | message format. Defaults to txt,html. Set to txt to send only the plain-text part |
| format_txt | string | message 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_openings | boolean | whether to track opens. Defaults to true |
| trace_clicks | boolean | whether to track link clicks. Defaults to true |
| trace_txt_clicks | boolean | whether to track link clicks in the plain-text message. Defaults to true |
| attachments | array | array 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);