dolibarr 23.0.3
actions_sendmails.inc.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
4 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
5* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
6*
7* This program is free software; you can redistribute it and/or modify
8* it under the terms of the GNU General Public License as published by
9* the Free Software Foundation; either version 3 of the License, or
10* (at your option) any later version.
11*
12* This program is distributed in the hope that it will be useful,
13* but WITHOUT ANY WARRANTY; without even the implied warranty of
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15* GNU General Public License for more details.
16*
17* You should have received a copy of the GNU General Public License
18* along with this program. If not, see <https://www.gnu.org/licenses/>.
19* or see https://www.gnu.org/
20*/
21
47'
48@phan-var-force Societe $mysoc
49@phan-var-force CommonObject $object
50';
51
52$error = 0;
53
54/*
55 * Add file in email form
56 */
57if (GETPOST('addfile', 'alpha')) {
58 $trackid = GETPOST('trackid', 'aZ09');
59
60 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
61
62 // Set tmp user directory
63 $vardir = $conf->user->dir_output."/".$user->id;
64 $upload_dir_tmp = $vardir.'/temp'; // TODO Add $keytoavoidconflict in upload_dir path
65
66 dol_add_file_process($upload_dir_tmp, 1, 0, 'addedfile', '', null, $trackid, 0);
67 $action = 'presend';
68}
69
70/*
71 * Remove file in email form
72 */
73if (GETPOST('removedfile') && !GETPOST('removeAll')) {
74 $trackid = GETPOST('trackid', 'aZ09');
75
76 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
77
78 // Set tmp user directory
79 $vardir = $conf->user->dir_output."/".$user->id;
80 $upload_dir_tmp = $vardir.'/temp'; // TODO Add $keytoavoidconflict in upload_dir path
81
82 // TODO Delete only files that was uploaded from email form. This can be addressed by adding the trackid into the temp path then changing donotdeletefile to 2 instead of 1 to say "delete only if into temp dir"
83 // GETPOST('removedfile','alpha') is position of file into $_SESSION["listofpaths"...] array.
84 dol_remove_file_process(GETPOSTINT('removedfile'), 0, 1, $trackid); // We do not delete because if file is the official PDF of doc, we don't want to remove it physically
85 $action = 'presend';
86}
87
88/*
89 * Remove all files in email form
90 */
91if (GETPOST('removeAll', 'alpha')) {
92 $trackid = GETPOST('trackid', 'aZ09');
93
94 $listofpaths = array();
95 $listofnames = array();
96 $listofmimes = array();
97 $keytoavoidconflict = empty($trackid) ? '' : '-'.$trackid;
98 if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) {
99 $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
100 }
101 if (!empty($_SESSION["listofnames".$keytoavoidconflict])) {
102 $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
103 }
104 if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) {
105 $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
106 }
107
108 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
109 $formmail = new FormMail($db);
110 $formmail->trackid = $trackid;
111
112 foreach ($listofpaths as $key => $value) {
113 $pathtodelete = $value;
114 $filetodelete = $listofnames[$key];
115 $result = dol_delete_file($pathtodelete, 1); // Delete uploaded Files
116
117 $langs->load("other");
118 setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs');
119
120 $formmail->remove_attached_files($key); // Update Session
121 }
122}
123
124/*
125 * Send mail
126 */
127if (($action == 'send' || $action == 'relance') && !GETPOST('addfile') && !GETPOST('removeAll') && !GETPOST('removedfile') && !GETPOST('cancel') && !GETPOST('modelselected')) {
128 if (empty($trackid)) {
129 $trackid = GETPOST('trackid', 'aZ09');
130 }
131
132 // Set tmp user directory (used to convert images embedded as img src=data:image)
133 $vardir = $conf->user->dir_output."/".$user->id;
134 $upload_dir_tmp = $vardir.'/temp'; // TODO Add $keytoavoidconflict in upload_dir path
135
136 $subject = '';
137 //$actionmsg = '';
138 $actionmsg2 = '';
139 $thirdparty = null;
140 $contact = null;
141 $result = 0;
142
143 $langs->load('mails');
144
145 $sendtosocid = 0; // Id of related thirdparty
146
147 if (is_object($object)) {
148 $result = $object->fetch($id);
149
150 if (method_exists($object, "fetch_thirdparty") && !in_array($object->element, array('member', 'user', 'expensereport', 'societe', 'contact'))) {
151 $object->fetch_thirdparty();
152 $thirdparty = $object->thirdparty;
153 if (is_object($thirdparty)) {
154 $sendtosocid = $thirdparty->id;
155 }
156 } elseif ($object->element == 'member' || $object->element == 'user') {
157 $thirdparty = $object;
158 if ($object->socid > 0) {
159 $sendtosocid = $object->socid;
160 }
161 } elseif ($object->element == 'expensereport') {
162 $tmpuser = new User($db);
163 $tmpuser->fetch($object->fk_user_author);
164 $thirdparty = $tmpuser;
165 if ($object->socid > 0) {
166 $sendtosocid = $object->socid;
167 }
168 } elseif ($object->element == 'societe') {
169 $thirdparty = $object;
170 if (is_object($thirdparty) && $thirdparty->id > 0) {
171 $sendtosocid = $thirdparty->id;
172 }
173 } elseif ($object->element == 'contact') {
174 $contact = $object;
175 if ($contact->id > 0) {
176 $contact->fetch_thirdparty();
177 $thirdparty = $contact->thirdparty;
178 if (is_object($thirdparty) && $thirdparty->id > 0) {
179 $sendtosocid = $thirdparty->id;
180 }
181 }
182 } else {
183 dol_print_error(null, "Use actions_sendmails.in.php for an element/object '".$object->element."' that is not supported");
184 }
185
186 if (is_object($hookmanager)) {
187 $parameters = array();
188 $reshook = $hookmanager->executeHooks('initSendToSocid', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
189 }
190 } else {
191 $thirdparty = $mysoc;
192 $result = 1; // No object to fetch (e.g. Setup -> Emails -> send test email): consider OK
193 }
194
195 if ($result > 0) {
196 $from = '';
197 $sendto = '';
198 $sendtocc = '';
199 $sendtobcc = '';
200 $sendtoid = array();
201 $sendtouserid = array();
202 $sendtoccuserid = array();
203
204 // Define $sendto
205 $receiver = GETPOST('receiver', 'alphawithlgt');
206 if (!is_array($receiver)) {
207 if ($receiver == '-1') {
208 $receiver = array();
209 } else {
210 $receiver = array($receiver);
211 }
212 }
213
214 $tmparray = array();
215 if (trim(GETPOST('sendto', 'alphawithlgt'))) {
216 // Recipients are provided into free text field
217 $tmparray[] = trim(GETPOST('sendto', 'alphawithlgt'));
218 }
219
220 if (trim(GETPOST('tomail', 'alphawithlgt'))) {
221 // Recipients are provided into free hidden text field
222 $tmparray[] = trim(GETPOST('tomail', 'alphawithlgt'));
223 }
224
225 if (count($receiver) > 0) {
226 // Recipient was provided from combo list
227 foreach ($receiver as $key => $val) {
228 if ($val == 'thirdparty') { // Key selected means current third party ('thirdparty' may be used for current member or current user too)
229 $tmparray[] = dol_string_nospecial($thirdparty->getFullName($langs), ' ', array(",")).' <'.$thirdparty->email.'>';
230 } elseif ($val == 'contact') { // Key selected means current contact
231 $tmparray[] = dol_string_nospecial($contact->getFullName($langs), ' ', array(",")).' <'.$contact->email.'>';
232 $sendtoid[] = $contact->id;
233 } elseif ($val && $object->element == 'project' && empty($object->socid)) { // $val is the Id of a contact
234 $contact = new Contact($db);
235 $ret = $contact->fetch((int) $val);
236 if ($ret > 0 && !empty($contact->socid)) {
237 $thirdparty = new Societe($db);
238 $thirdparty->fetch($contact->socid);
239 $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email');
240 $sendtoid[] = ((int) $val);
241 }
242 } elseif ($val) { // $val is the Id of a contact
243 $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email');
244 $sendtoid[] = ((int) $val);
245 }
246 }
247 }
248
249 if (getDolGlobalString('MAIN_MAIL_ENABLED_USER_DEST_SELECT')) {
250 $receiveruser = GETPOST('receiveruser', 'alphawithlgt');
251 if (is_array($receiveruser) && count($receiveruser) > 0) {
252 $fuserdest = new User($db);
253 foreach ($receiveruser as $key => $val) {
254 $tmparray[] = $fuserdest->user_get_property($val, 'email');
255 $sendtouserid[] = $val;
256 }
257 }
258 }
259
260 $sendto = implode(',', $tmparray);
261
262 // Define $sendtocc
263 $receivercc = GETPOST('receivercc', 'alphawithlgt');
264 if (!is_array($receivercc)) {
265 if ($receivercc == '-1') {
266 $receivercc = array();
267 } else {
268 $receivercc = array($receivercc);
269 }
270 }
271 $tmparray = array();
272 if (trim(GETPOST('sendtocc', 'alphawithlgt'))) {
273 $tmparray[] = trim(GETPOST('sendtocc', 'alphawithlgt'));
274 }
275 if (count($receivercc) > 0) {
276 foreach ($receivercc as $key => $val) {
277 if ($val == 'thirdparty') { // Key selected means current thirdparty (may be usd for current member or current user too)
278 // Recipient was provided from combo list
279 $tmparray[] = dol_string_nospecial((string) $thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>';
280 } elseif ($val == 'contact') { // Key selected means current contact
281 // Recipient was provided from combo list
282 $tmparray[] = dol_string_nospecial((string) $contact->name, ' ', array(",")).' <'.$contact->email.'>';
283 //$sendtoid[] = $contact->id; TODO Add also id of contact in CC ?
284 } elseif ($val) { // $val is the Id of a contact
285 $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email');
286 //$sendtoid[] = ((int) $val); TODO Add also id of contact in CC ?
287 }
288 }
289 }
290 if (getDolGlobalString('MAIN_MAIL_ENABLED_USER_DEST_SELECT')) {
291 $receiverccuser = GETPOST('receiverccuser', 'alphawithlgt');
292
293 if (is_array($receiverccuser) && count($receiverccuser) > 0) {
294 $fuserdest = new User($db);
295 foreach ($receiverccuser as $key => $val) {
296 $tmparray[] = $fuserdest->user_get_property($val, 'email');
297 $sendtoccuserid[] = $val;
298 }
299 }
300 }
301 $sendtocc = implode(',', $tmparray);
302
303 if (dol_strlen($sendto)) {
304 // Define $urlwithroot
305 $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
306 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
307 //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
308
309 require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
310
311 $langs->load("commercial");
312
313 $reg = array();
314 $fromtype = GETPOST('fromtype', 'alpha');
315 $emailsendersignature = '';
316 if ($fromtype === 'robot') {
317 $from = dol_string_nospecial(getDolGlobalString('MAIN_MAIL_EMAIL_FROM'), ' ', array(",")).' <' . getDolGlobalString('MAIN_MAIL_EMAIL_FROM').'>';
318 } elseif ($fromtype === 'user') {
319 $from = dol_string_nospecial($user->getFullName($langs), ' ', array(",")).' <'.$user->email.'>';
320 } elseif ($fromtype === 'company') {
321 $from = dol_string_nospecial(getDolGlobalString('MAIN_INFO_SOCIETE_NOM'), ' ', array(",")).' <' . getDolGlobalString('MAIN_INFO_SOCIETE_MAIL').'>';
322 } elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) {
323 $tmp = explode(',', $user->email_aliases);
324 $from = trim($tmp[((int) $reg[1] - 1)]);
325 } elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) {
326 $tmp = explode(',', getDolGlobalString('MAIN_INFO_SOCIETE_MAIL_ALIASES'));
327 $from = trim($tmp[((int) $reg[1] - 1)]);
328 } elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
329 $sql = 'SELECT rowid, label, email, signature FROM '.MAIN_DB_PREFIX.'c_email_senderprofile';
330 $sql .= ' WHERE rowid = '.(int) $reg[1];
331 $resql = $db->query($sql);
332 $obj = $db->fetch_object($resql);
333 if ($obj) {
334 $from = dol_string_nospecial($obj->label, ' ', array(",")).' <'.$obj->email.'>';
335 $emailsendersignature = $obj->signature;
336 }
337 } elseif (preg_match('/from_template_(\d+)/', $fromtype, $reg)) {
338 $sql = 'SELECT rowid, email_from FROM '.MAIN_DB_PREFIX.'c_email_templates';
339 $sql .= ' WHERE rowid = '.(int) $reg[1];
340 $resql = $db->query($sql);
341 $obj = $db->fetch_object($resql);
342 if ($obj) {
343 $from = $obj->email_from;
344 }
345 } else {
346 $from = dol_string_nospecial(GETPOST('fromname'), ' ', array(",")).' <'.GETPOST('frommail').'>';
347 }
348
349 $replyto = '';
350 if (GETPOST('replytomail')) {
351 $replyto = dol_string_nospecial(GETPOST('replytoname'), ' ', array(","));
352 $replyto .= ($replyto ? ' ' : '').'<'.GETPOST('replytomail').'>';
353 }
354
355 $message = GETPOST('message', 'restricthtml');
356 $subject = GETPOST('subject', 'restricthtml');
357
358 // Make a change into HTML code to allow to include images from medias directory with an external reabable URL.
359 // <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
360 // become
361 // <img alt="" src="'.$urlwithroot.'viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
362 $message = preg_replace('/(<img.*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/>)/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $message);
363
364 $sendtobcc = GETPOST('sendtoccc', 'alphawithlgt');
365 // Autocomplete the $sendtobcc
366 // $autocopy can be MAIN_MAIL_AUTOCOPY_PROPOSAL_TO, MAIN_MAIL_AUTOCOPY_ORDER_TO, MAIN_MAIL_AUTOCOPY_INVOICE_TO, MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO...
367 if (!empty($autocopy)) {
368 $sendtobcc .= (getDolGlobalString($autocopy) ? (($sendtobcc ? ", " : "") . getDolGlobalString($autocopy)) : '');
369 }
370
371 $deliveryreceipt = GETPOSTINT('deliveryreceipt') ? 1 : 0;
372
373 if ($action == 'send' || $action == 'relance') {
374 $actionmsg2 = $langs->transnoentities('MailSentByTo', CMailFile::getValidAddress($from, 4, 0, 1), CMailFile::getValidAddress($sendto, 4, 0, 1));
375 /*if ($message) {
376 $actionmsg = $langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from);
377 $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto));
378 if ($sendtocc) {
379 $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".dol_escape_htmltag($sendtocc));
380 }
381 $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject);
382 $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":");
383 $actionmsg = dol_concatdesc($actionmsg, $message);
384 }*/
385 }
386
387 // Create form object
388 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
389 $formmail = new FormMail($db);
390 $formmail->trackid = $trackid; // $trackid must be defined
391
392 $attachedfiles = $formmail->get_attached_files();
393 $filepath = $attachedfiles['paths'];
394 $filename = $attachedfiles['names'];
395 $mimetype = $attachedfiles['mimes'];
396
397 // Make substitution in email content
398 $substitutionarray = getCommonSubstitutionArray($langs, 0, null, $object);
399
400 $substitutionarray['__SENDEREMAIL_SIGNATURE__'] = (empty($emailsendersignature) ? $user->signature : $emailsendersignature);
401 $substitutionarray['__EMAIL__'] = $sendto;
402 $substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag=undefined&securitykey='.dol_hash(getDolGlobalString('MAILING_EMAIL_UNSUBSCRIBE_KEY')."-undefined", 'md5').'" width="1" height="1" style="width:1px;height:1px" border="0"/>' : '';
403
404 $parameters = array('mode' => 'formemail');
405 complete_substitutions_array($substitutionarray, $langs, $object, $parameters);
406
407 $subject = make_substitutions($subject, $substitutionarray);
408 $message = make_substitutions($message, $substitutionarray);
409
410 if (is_object($object) && method_exists($object, 'makeSubstitution')) {
411 $subject = $object->makeSubstitution($subject);
412 $message = $object->makeSubstitution($message);
413 }
414
415 // Send mail (substitutionarray must be done just before this)
416 if (empty($sendcontext)) {
417 $sendcontext = 'standard';
418 }
419 $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1, '', '', $trackid, '', $sendcontext, $replyto, $upload_dir_tmp);
420
421 if (!empty($mailfile->error) || !empty($mailfile->errors)) {
422 setEventMessages($mailfile->error, $mailfile->errors, 'errors');
423 $action = 'presend';
424 } else {
425 $result = $mailfile->sendfile();
426 if ($result) {
427 // Initialisation of datas of object to call trigger
428 if (is_object($object)) {
429 $db->begin(); // Transaction for post action must start after sending email to avoid lock when sending email that may be long
430
431 if (empty($actiontypecode)) {
432 $actiontypecode = 'AC_OTH_AUTO'; // Event inserted into agenda automatically
433 }
434
435 $object->socid = $sendtosocid; // To link to a company
436 $object->sendtoid = $sendtoid; // To link to contact-addresses. This is an array.
437 $object->actiontypecode = $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
438 $object->actionmsg = $message; // Long text
439 $object->actionmsg2 = $actionmsg2; // Short text ($langs->transnoentities('MailSentByTo')...);
440 if (getDolGlobalString('MAIN_MAIL_REPLACE_EVENT_TITLE_BY_EMAIL_SUBJECT')) {
441 $object->actionmsg2 = $subject; // Short text
442 }
443
444 $object->trackid = $trackid;
445 $object->fk_element = $object->id;
446 $object->elementtype = $object->element;
447 if (is_array($attachedfiles) && count($attachedfiles) > 0) {
448 $object->attachedfiles = $attachedfiles;
449 }
450 if (is_array($sendtouserid) && count($sendtouserid) > 0 && getDolGlobalString('MAIN_MAIL_ENABLED_USER_DEST_SELECT')) {
451 $object->sendtouserid = $sendtouserid;
452 }
453
454 // TODO Fix this: Such properties does not exists on all objects
455 $object->context['email_msgid'] = $mailfile->msgid;
456 $object->context['email_from'] = $from;
457 $object->context['email_subject'] = $subject;
458 $object->context['email_to'] = $sendto;
459 $object->context['email_tocc'] = $sendtocc;
460 $object->context['email_tobcc'] = $sendtobcc;
461
462 $object->email_msgid = $mailfile->msgid; // @todo Set msgid into $mailfile after sending
463 $object->email_from = $from;
464 $object->email_subject = $subject;
465 $object->email_to = $sendto;
466 $object->email_tocc = $sendtocc;
467 $object->email_tobcc = $sendtobcc;
468
469 // Call of triggers (you should have set $triggersendname to execute trigger.
470 if (!empty($triggersendname)) {
471 if ($triggersendname == 'BILL_SENTBYMAIL' && $object instanceof Facture) {
472 /* @var Facture $object */
473
474 // If sending email for invoice, we increase the counter of invoices sent by email
475 $sql = "UPDATE ".MAIN_DB_PREFIX."facture SET email_sent_counter = email_sent_counter + 1";
476 $sql .= " WHERE rowid = ".((int) $object->id);
477
478 $db->query($sql);
479
480 $object->email_sent_counter += 1;
481 }
482
483 $result = $object->call_trigger($triggersendname, $user); // @phan-suppress-current-line PhanPossiblyUndeclaredGlobalVariable
484 if ($result < 0) {
485 $error++;
486 }
487 if ($error) {
488 setEventMessages($object->error, $object->errors, 'errors');
489 }
490 }
491 // End call of triggers
492
493 if (!$error) {
494 $db->commit();
495 } else {
496 $db->rollback();
497 }
498 }
499
500 // Redirect here
501 // This avoid sending mail twice if going out and then back to page
502 $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2));
503 setEventMessages($mesg, null, 'mesgs');
504
505 header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname ?? 'id').'='.(is_object($object) ? $object->id : ''));
506 exit;
507 } else {
508 $langs->load("other");
509 $mesg = '<div class="error">';
510 if (!empty($mailfile->error) || !empty($mailfile->errors)) {
511 $mesg .= $langs->transnoentities('ErrorFailedToSendMail', dol_escape_htmltag($from), dol_escape_htmltag($sendto));
512 if (!empty($mailfile->error)) {
513 $mesg .= '<br>'.$mailfile->error;
514 }
515 if (!empty($mailfile->errors) && is_array($mailfile->errors)) {
516 $mesg .= '<br>'.implode('<br>', $mailfile->errors);
517 }
518 } else {
519 $mesg .= $langs->transnoentities('ErrorFailedToSendMail', dol_escape_htmltag($from), dol_escape_htmltag($sendto));
520 if (getDolGlobalString('MAIN_DISABLE_ALL_MAILS')) {
521 $mesg .= '<br>Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
522 } else {
523 $mesg .= '<br>Unknown Error, please refer to your administrator';
524 }
525 }
526 $mesg .= '</div>';
527
528 setEventMessages($mesg, null, 'warnings');
529 $action = 'presend';
530 }
531 }
532 } else {
533 $langs->load("errors");
534 setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("MailTo")), null, 'warnings');
535 dol_syslog('Try to send email with no recipient defined', LOG_WARNING);
536 $action = 'presend';
537 }
538 } else {
539 $langs->load("errors");
540 setEventMessages($langs->trans('ErrorFailedToReadObject', $object->element), null, 'errors');
541 dol_syslog('Failed to read data of object id='.$object->id.' element='.$object->element);
542 $action = 'presend';
543 }
544}
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
global $dolibarr_main_url_root
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
static getValidAddress($address, $format, $encode=0, $maxnumberofemail=0)
Return a formatted address string for SMTP protocol.
Class to manage contact/addresses.
Class to manage invoices.
Class permettant la generation du formulaire html d'envoi de mail unitaire Usage: $formail = new Form...
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
global $mysoc
dol_add_file_process($upload_dir, $allowoverwrite=0, $updatesessionordb=0, $keyforsourcefile='addedfile', $savingdocmask='', $link=null, $trackid='', $generatethumbs=1, $object=null, $forceFullTextIndexation='', $mode=0)
Get and save an upload file (for example after submitting a new file in a mail form).
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_remove_file_process($filenb, $donotupdatesession=0, $donotdeletefile=1, $trackid='')
Remove an uploaded file (for example after submitting a new file a mail form).
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_string_nospecial($str, $newstr='_', $badcharstoreplace='', $badcharstoremove='', $keepspaces=0)
Clean a string from all punctuation characters to use it as a ref or login.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
dol_hash($chain, $type='0', $nosalt=0, $mode=0)
Returns a hash (non reversible encryption) of a string.