|
dolibarr 19.0.4
|
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...
Public Member Functions | |
| __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. | |
| sendfile () | |
| Send mail that was prepared by constructor. | |
| dump_mail () | |
| Write content of a SMTP request into a dump file (mode = all) Used for debugging. | |
| save_dump_mail_in_err ($message='') | |
| Save content if mail is in error Used for debugging. | |
| checkIfHTML ($msg) | |
| Correct an uncomplete html string. | |
| buildCSS () | |
| Build a css style (mode = all) into this->styleCSS and this->bodyCSS. | |
| write_smtpheaders () | |
| Create SMTP headers (mode = 'mail') | |
| write_mimeheaders ($filename_list, $mimefilename_list) | |
| Create header MIME (mode = 'mail') | |
| write_body ($msgtext) | |
| Return email content (mode = 'mail') | |
| write_images ($images_list) | |
| Attach an image to email (mode = 'mail') | |
| check_server_port ($host, $port) | |
| Try to create a socket connection. | |
| server_parse ($socket, $response) | |
| This function has been modified as provided by SirSir to allow multiline responses when using SMTP Extensions. | |
Static Public Member Functions | |
| static | encodetorfc2822 ($stringtoencode) |
| Encode subject according to RFC 2822 - http://en.wikipedia.org/wiki/MIME#Encoded-Word. | |
| static | getValidAddress ($address, $format, $encode=0, $maxnumberofemail=0) |
| Return a formatted address string for SMTP protocol. | |
| static | getArrayAddress ($address) |
| Return a formatted array of address string for SMTP protocol. | |
Public Attributes | |
| $styleCSS | |
| Defined css style for body background. | |
| $bodyCSS | |
| Defined background directly in body tag. | |
Private Member Functions | |
| _encode_file ($sourcefile) | |
| Read a file on disk and return encoded content for emails (mode = 'mail') | |
| write_files ($filename_list, $mimetype_list, $mimefilename_list, $cidlist) | |
| Attach file to email (mode = 'mail') | |
| findHtmlImages ($images_dir) | |
| Search images into html message and init array this->images_encoded if found. | |
| findHtmlImagesIsSrcData ($images_dir) | |
| Seearch images with data:image format into html message. | |
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 42 of file CMailFile.class.php.
| 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 = '' ) |
| 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', 'ticket', 'password', ... (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 177 of file CMailFile.class.php.
References ascii_check(), buildCSS(), checkIfHTML(), dol_nl2br(), dol_sanitizeEmail(), dol_string_unaccent(), dol_syslog(), dol_textishtml(), encodetorfc2822(), findHtmlImages(), findHtmlImagesIsSrcData(), getArrayAddress(), getDolGlobalString(), getValidAddress(), write_body(), write_files(), write_mimeheaders(), and write_smtpheaders().
|
private |
Read a file on disk and return encoded content for emails (mode = 'mail')
| string | $sourcefile | Path to file to encode |
Definition at line 1277 of file CMailFile.class.php.
References dol_osencode(), and dol_syslog().
Referenced by write_files().
| CMailFile::buildCSS | ( | ) |
Build a css style (mode = all) into this->styleCSS and this->bodyCSS.
Definition at line 1410 of file CMailFile.class.php.
Referenced by __construct().
| CMailFile::check_server_port | ( | $host, | |
| $port ) |
Try to create a socket connection.
| string | $host | Add ssl:// for SSL/TLS. |
| int | $port | Example: 25, 465 |
Definition at line 1718 of file CMailFile.class.php.
References dol_syslog(), getDolGlobalString(), server_parse(), and utf8_check().
| CMailFile::checkIfHTML | ( | $msg | ) |
Correct an uncomplete html string.
| string | $msg | String |
Definition at line 1384 of file CMailFile.class.php.
References $bodyCSS, and $styleCSS.
Referenced by __construct(), and write_body().
| CMailFile::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"
Definition at line 1302 of file CMailFile.class.php.
References dol_move(), dol_now(), dol_print_date(), dolChmod(), and getDolGlobalString().
Referenced by sendfile().
|
static |
Encode subject according to RFC 2822 - http://en.wikipedia.org/wiki/MIME#Encoded-Word.
| string | $stringtoencode | String to encode |
Definition at line 1264 of file CMailFile.class.php.
Referenced by __construct(), and sendfile().
|
private |
Search images into html message and init array this->images_encoded if found.
| string | $images_dir | Location of physical images files. For example $dolibarr_main_data_root.'/medias' |
Definition at line 1825 of file CMailFile.class.php.
References dol_hash().
Referenced by __construct().
|
private |
Seearch images with data:image format into html message.
If we find some, we create it on disk.
| string | $images_dir | Location of where to store physicaly images files. For example $dolibarr_main_data_root.'/medias' |
Definition at line 1913 of file CMailFile.class.php.
References dol_is_dir(), dol_is_file(), dol_mkdir(), dol_syslog(), and dolChmod().
Referenced by __construct().
|
static |
Return a formatted array of address string for SMTP protocol.
| 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' |
Definition at line 2082 of file CMailFile.class.php.
References getDolGlobalString().
Referenced by __construct().
|
static |
Return a formatted address string for SMTP protocol.
| 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 @param int $encode 0=No encode name, 1=Encode name to RFC2822 @param int $maxnumberofemail 0=No limit. Otherwise, maximum number of emails returned ($address may contains several email separated with ','). Add '...' if there is more. @return string If format 0: '<john@doe.com>' or 'John Doe <john@doe.com>' or '=?UTF-8?B?Sm9obiBEb2U=?= <john@doe.com>' If format 1: '<john@doe.com>' If format 2: 'john@doe.com' If format 3: '<john@doe.com>' or '"John Doe" <john@doe.com>' or '"=?UTF-8?B?Sm9obiBEb2U=?=" <john@doe.com>' If format 4: 'John Doe' or 'john@doe.com' if no label exists If format 5: <a href="john@.nosp@m.doe..nosp@m.com">John Doe</a> or <a href="john@.nosp@m.doe..nosp@m.com">john@.nosp@m.doe..nosp@m.com if no label exists |
Definition at line 2013 of file CMailFile.class.php.
References getDolGlobalString().
Referenced by __construct(), sendfile(), Adherent\sendReminderForExpiredSubscription(), and showDirectPublicLink().
| CMailFile::save_dump_mail_in_err | ( | $message = '' | ) |
Save content if mail is in error Used for debugging.
| string | $message | Add also a message |
Definition at line 1342 of file CMailFile.class.php.
References dol_move(), dol_now(), dol_print_date(), dolChmod(), and getDolGlobalString().
Referenced by sendfile().
| CMailFile::sendfile | ( | ) |
Send mail that was prepared by constructor.
Definition at line 678 of file CMailFile.class.php.
References ascii_check(), dol_syslog(), dump_mail(), encodetorfc2822(), getDolGlobalInt(), getDolGlobalString(), getSupportedOauth2Array(), getValidAddress(), and save_dump_mail_in_err().
| CMailFile::server_parse | ( | $socket, | |
| $response ) |
This function has been modified as provided by SirSir to allow multiline responses when using SMTP Extensions.
| resource | $socket | Socket |
| string | $response | Response string |
Definition at line 1798 of file CMailFile.class.php.
Referenced by check_server_port().
| CMailFile::write_body | ( | $msgtext | ) |
Return email content (mode = 'mail')
| string | $msgtext | Message string |
Definition at line 1542 of file CMailFile.class.php.
References checkIfHTML(), getDolGlobalString(), and write_images().
Referenced by __construct().
|
private |
Attach file to email (mode = 'mail')
| 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 |
Definition at line 1638 of file CMailFile.class.php.
References _encode_file(), and dol_syslog().
Referenced by __construct().
| CMailFile::write_images | ( | $images_list | ) |
Attach an image to email (mode = 'mail')
| array | $images_list | Array of array image |
Definition at line 1686 of file CMailFile.class.php.
References dol_syslog().
Referenced by write_body().
| CMailFile::write_mimeheaders | ( | $filename_list, | |
| $mimefilename_list ) |
Create header MIME (mode = 'mail')
| array | $filename_list | Array of filenames |
| array | $mimefilename_list | Array of mime types |
Definition at line 1513 of file CMailFile.class.php.
References dol_syslog().
Referenced by __construct().
| CMailFile::write_smtpheaders | ( | ) |
Create SMTP headers (mode = 'mail')
Definition at line 1437 of file CMailFile.class.php.
References dol_syslog(), and getDolGlobalString().
Referenced by __construct().