Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filepath,$mimetype,$filename,$cc,$ccc,$deliveryreceipt,$msgishtml,$errors_to,$css,$trackid,$moreinheader,$sendcontext,$replyto); $mailfile->sendfile();.
More...
|
| __construct ($subject, $to, $from, $msg, $filename_list=array(), $mimetype_list=array(), $mimefilename_list=array(), $addr_cc="", $addr_bcc="", $deliveryreceipt=0, $msgishtml=0, $errors_to='', $css='', $trackid='', $moreinheader='', $sendcontext='standard', $replyto='', $upload_dir_tmp='') |
| CMailFile. More...
|
|
| sendfile () |
| Send mail that was prepared by constructor. More...
|
|
| dump_mail () |
| Write content of a SMTP request into a dump file (mode = all) Used for debugging. More...
|
|
| checkIfHTML ($msg) |
| Correct an uncomplete html string. More...
|
|
| buildCSS () |
| Build a css style (mode = all) into this->styleCSS and this->bodyCSS. More...
|
|
| write_smtpheaders () |
| Create SMTP headers (mode = 'mail') More...
|
|
| write_mimeheaders ($filename_list, $mimefilename_list) |
| Create header MIME (mode = 'mail') More...
|
|
| write_body ($msgtext) |
| Return email content (mode = 'mail') More...
|
|
| write_images ($images_list) |
| Attach an image to email (mode = 'mail') More...
|
|
| check_server_port ($host, $port) |
| Try to create a socket connection. More...
|
|
| server_parse ($socket, $response) |
| This function has been modified as provided by SirSir to allow multiline responses when using SMTP Extensions. More...
|
|
|
| $styleCSS |
| Defined css style for body background.
|
|
| $bodyCSS |
| Defined background directly in body tag.
|
|
|
| _encode_file ($sourcefile) |
| Read a file on disk and return encoded content for emails (mode = 'mail') More...
|
|
| write_files ($filename_list, $mimetype_list, $mimefilename_list, $cidlist) |
| Attach file to email (mode = 'mail') More...
|
|
| findHtmlImages ($images_dir) |
| Seearch images into html message and init array this->images_encoded if found. More...
|
|
| findHtmlImagesIsSrcData ($images_dir) |
| Seearch images with data:image format into html message. More...
|
|
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filepath,$mimetype,$filename,$cc,$ccc,$deliveryreceipt,$msgishtml,$errors_to,$css,$trackid,$moreinheader,$sendcontext,$replyto); $mailfile->sendfile();.
Definition at line 40 of file CMailFile.class.php.
◆ __construct()
CMailFile::__construct |
( |
|
$subject, |
|
|
|
$to, |
|
|
|
$from, |
|
|
|
$msg, |
|
|
|
$filename_list = array() , |
|
|
|
$mimetype_list = array() , |
|
|
|
$mimefilename_list = array() , |
|
|
|
$addr_cc = "" , |
|
|
|
$addr_bcc = "" , |
|
|
|
$deliveryreceipt = 0 , |
|
|
|
$msgishtml = 0 , |
|
|
|
$errors_to = '' , |
|
|
|
$css = '' , |
|
|
|
$trackid = '' , |
|
|
|
$moreinheader = '' , |
|
|
|
$sendcontext = 'standard' , |
|
|
|
$replyto = '' , |
|
|
|
$upload_dir_tmp = '' |
|
) |
| |
CMailFile.
- Parameters
-
string | $subject | Topic/Subject of mail |
string | $to | Recipients emails (RFC 2822: "Name firstname <email>[, ...]" or "email[, ...]" or "<email>[, ...]"). Note: the keyword 'SUPERVISOREMAIL' is not allowed here and must be replaced by caller. |
string | $from | Sender email (RFC 2822: "Name firstname <email>[, ...]" or "email[, ...]" or "<email>[, ...]") |
string | $msg | Message |
array | $filename_list | List of files to attach (full path of filename on file system) |
array | $mimetype_list | List of MIME type of attached files |
array | $mimefilename_list | List of attached file name in message |
string | $addr_cc | Email cc (Example: 'abc@d.nosp@m.ef.c.nosp@m.om, ghk@l.nosp@m.mn.c.nosp@m.om') |
string | $addr_bcc | Email bcc (Note: This is autocompleted with MAIN_MAIL_AUTOCOPY_TO if defined) |
int | $deliveryreceipt | Ask a delivery receipt |
int | $msgishtml | 1=String IS already html, 0=String IS NOT html, -1=Unknown make autodetection (with fast mode, not reliable) |
string | $errors_to | Email for errors-to |
string | $css | Css option |
string | $trackid | Tracking string (contains type and id of related element) |
string | $moreinheader | More in header. $moreinheader must contains the "\r\n" (TODO not supported for other MAIL_SEND_MODE different than 'mail' and 'smtps' for the moment) |
string | $sendcontext | 'standard', 'emailing', ... (used to define which sending mode and parameters to use) |
string | $replyto | Reply-to email (will be set to same value than From by default if not provided) |
string | $upload_dir_tmp | Temporary directory (used to convert images embedded as img src=data:image) |
Definition at line 168 of file CMailFile.class.php.
◆ _encode_file()
CMailFile::_encode_file |
( |
|
$sourcefile | ) |
|
|
private |
Read a file on disk and return encoded content for emails (mode = 'mail')
- Parameters
-
string | $sourcefile | Path to file to encode |
- Returns
- int|string <0 if KO, encoded string if OK
Definition at line 1164 of file CMailFile.class.php.
References dol_osencode().
◆ buildCSS()
Build a css style (mode = all) into this->styleCSS and this->bodyCSS.
- Returns
- string
Definition at line 1248 of file CMailFile.class.php.
◆ check_server_port()
CMailFile::check_server_port |
( |
|
$host, |
|
|
|
$port |
|
) |
| |
Try to create a socket connection.
- Parameters
-
string | $host | Add ssl:// for SSL/TLS. |
int | $port | Example: 25, 465 |
- Returns
- int Socket id if ok, 0 if KO
Definition at line 1556 of file CMailFile.class.php.
◆ checkIfHTML()
CMailFile::checkIfHTML |
( |
|
$msg | ) |
|
Correct an uncomplete html string.
- Parameters
-
- Returns
- string Completed string
Definition at line 1222 of file CMailFile.class.php.
◆ dump_mail()
Write content of a SMTP request into a dump file (mode = all) Used for debugging.
Note that to see full SMTP protocol, you can use tcpdump -w /tmp/smtp -s 2000 port 25"
- Returns
- void
Definition at line 1189 of file CMailFile.class.php.
◆ encodetorfc2822()
static CMailFile::encodetorfc2822 |
( |
|
$stringtoencode | ) |
|
|
static |
◆ findHtmlImages()
CMailFile::findHtmlImages |
( |
|
$images_dir | ) |
|
|
private |
Seearch images into html message and init array this->images_encoded if found.
- Parameters
-
string | $images_dir | Location of physical images files. For example $dolibarr_main_data_root.'/medias' |
- Returns
- int >0 if OK, <0 if KO
Definition at line 1662 of file CMailFile.class.php.
◆ findHtmlImagesIsSrcData()
CMailFile::findHtmlImagesIsSrcData |
( |
|
$images_dir | ) |
|
|
private |
Seearch images with data:image format into html message.
- Parameters
-
string | $images_dir | Location of where to store physicaly images files. For example $dolibarr_main_data_root.'/medias' |
- Returns
- int >0 if OK, <0 if KO
Definition at line 1749 of file CMailFile.class.php.
◆ getArrayAddress()
static CMailFile::getArrayAddress |
( |
|
$address | ) |
|
|
static |
◆ getValidAddress()
static CMailFile::getValidAddress |
( |
|
$address, |
|
|
|
$format, |
|
|
|
$encode = 0 , |
|
|
|
$maxnumberofemail = 0 |
|
) |
| |
|
static |
Return a formatted address string for SMTP protocol.
- Parameters
-
string | $address | Example: 'John Doe john@.nosp@m.doe..nosp@m.com, Alan Smith alan@.nosp@m.smit.nosp@m.h.com' or 'john@.nosp@m.doe..nosp@m.com, alan@.nosp@m.smit.nosp@m.h.com' |
int | $format | 0=auto, 1=emails with <>, 2=emails without <>, 3=auto + label between ", 4 label or email, 5 mailto link |
int | $encode | 0=No encode name, 1=Encode name to RFC2822 |
int | $maxnumberofemail | 0=No limit. Otherwise, maximum number of emails returned ($address may contains several email separated with ','). Add '...' if there is more. |
- Returns
- string If format 0: 'john@.nosp@m.doe..nosp@m.com' or 'John Doe john@.nosp@m.doe..nosp@m.com' or '=?UTF-8?B?Sm9obiBEb2U=?= john@.nosp@m.doe..nosp@m.com' If format 1: 'john@.nosp@m.doe..nosp@m.com' If format 2: 'john@.nosp@m.doe..nosp@m.com' If format 3: 'john@.nosp@m.doe..nosp@m.com' or '"John Doe" john@.nosp@m.doe..nosp@m.com' or '"=?UTF-8?B?Sm9obiBEb2U=?=" john@.nosp@m.doe..nosp@m.com' If format 4: 'John Doe' or 'john@.nosp@m.doe..nosp@m.com' if no label exists If format 5: John Doe or john@doe.com if no label exists
- See also
- getArrayAddress()
Definition at line 1837 of file CMailFile.class.php.
◆ sendfile()
Send mail that was prepared by constructor.
- Returns
- boolean True if mail sent, false otherwise
Definition at line 626 of file CMailFile.class.php.
◆ server_parse()
CMailFile::server_parse |
( |
|
$socket, |
|
|
|
$response |
|
) |
| |
This function has been modified as provided by SirSir to allow multiline responses when using SMTP Extensions.
- Parameters
-
resource | $socket | Socket |
string | $response | Response string |
- Returns
- boolean true if success
Definition at line 1635 of file CMailFile.class.php.
◆ write_body()
CMailFile::write_body |
( |
|
$msgtext | ) |
|
Return email content (mode = 'mail')
- Parameters
-
string | $msgtext | Message string |
- Returns
- string String content
Definition at line 1380 of file CMailFile.class.php.
◆ write_files()
CMailFile::write_files |
( |
|
$filename_list, |
|
|
|
$mimetype_list, |
|
|
|
$mimefilename_list, |
|
|
|
$cidlist |
|
) |
| |
|
private |
Attach file to email (mode = 'mail')
- Parameters
-
array | $filename_list | Tableau |
array | $mimetype_list | Tableau |
array | $mimefilename_list | Tableau |
array | $cidlist | Array of CID if file must be completed with CID code |
- Returns
- string String with files encoded
Definition at line 1476 of file CMailFile.class.php.
◆ write_images()
CMailFile::write_images |
( |
|
$images_list | ) |
|
Attach an image to email (mode = 'mail')
- Parameters
-
array | $images_list | Array of array image |
- Returns
- string Chaine images encodees
Definition at line 1524 of file CMailFile.class.php.
◆ write_mimeheaders()
CMailFile::write_mimeheaders |
( |
|
$filename_list, |
|
|
|
$mimefilename_list |
|
) |
| |
Create header MIME (mode = 'mail')
- Parameters
-
array | $filename_list | Array of filenames |
array | $mimefilename_list | Array of mime types |
- Returns
- string mime headers
Definition at line 1351 of file CMailFile.class.php.
◆ write_smtpheaders()
CMailFile::write_smtpheaders |
( |
| ) |
|
The documentation for this class was generated from the following file: