Customize the email sending message


If you are looking for ways to customize the messages created automatically when sending an invoice, a reminder or a proposal by email, here are some notes from a Dolibarr user that should make your task easier:

Personalize the sending of documents by E-mail

With Dolibarr, it is possible to send the documents directly by E-mail with the Send by E-mail button. A form appears to select the recipients and an automatic message is added in the message area.

Dolibarr >= 9

  • On Dolibarr versions greater than or equal to v9, it is enough to add an email template in the menu Tools - Email template.

If there are several models entered for the same context, Dolibarr will take the first one (the one with the weakest position field therefore)

Dolibarr <= 8

  • On Dolibarr versions lower than v8, the predefined message is saved in the Dolibarr languages folder

/htdocs/langs/en_en/other.lang

To customize this message, you must modify the following lines:

PredefinedMailContentSendInvoice=Please find attached the invoice __FACREF__\n\nRegards\n\n

PredefinedMailContentSendInvoiceReminder=We bring to your attention that the __FACREF__ invoice does not appear to have been paid. So here it is, as a reminder, as an attachment.\n\nRegards\n\n

PredefinedMailContentSendProposal=Please find attached the commercial proposal __PROPREF__\n\nRegards\n\n

PredefinedMailContentSendOrder=Please find attached the order form __ORDERREF__\n\nRegards\n\n

PredefinedMailContentSendSupplierOrder=Please find attached our order __ORDERREF__\n\nRegards\n\n

PredefinedMailContentSendSupplierInvoice=Please find attached the invoice __FACREF__\n\nRegards\n\n

Messages can be written either in HTML or plain text. If you choose a simple text format, you must write \n to make a line break. If you prefer a message formatted in HTML, just use the standard HTML tags to format your message ((<br> : carriage return, <b>my text</b> for bold etc...)

Customize variables on a Dolibarr version

Dolibarr >= 8

Many variables can be used in your email template. Here is a non-exhaustive list.

To make sure you have an up-to-date list, you can click on the "?" symbol next to the "Content" label when you create or modify your email template.

Dolibarr <= 7

When we look at the predefined messages we see that the part number is replaced by a variable __FACREF__, __ORDERREF__

To send invoices, if you want the following message:

Dear Sir,

Please find attached the invoice 2011-090

Invoice: 2011-090 Date: 27/07/2011 Amount: € 85.00

Please make the payment by bank transfer to the account whose bank details appear at the bottom of the invoice.

Sincerely

Computer 81

Computer 81 - 16, Portal Street - 81600 Gaillac - France Phone: 05.81.31.48.00 - 06.47.94.94.52.38 - Email: contact@computer81.com Web: www.computer81.com

So, to arrive at this result automatically, it is necessary to add the variables __FACDATE__ and __FACTOTALTTC__ To do this, we need to modify the following file:

/htdocs/compta/facture.php

do a search for "__FACREF__" in your editor and you will find the following line:

// Tableau des substitutions

$formmail->substit['__FACREF__']=$object->ref;

To add the variables insert the following 2 lines: 


$formmail->substit['__FACDATE__']=date('d/m/Y',$object->date);

$formmail->substit['__FACTOTALTTC__']=number_format($object->total_ttc,2,',',' ');

You can now insert the date and amount of the invoice in your automatic message.

If you need other variables to write your message, go to the file htdocs/compta/facture/class/facture.class.php

You will have the list of variables that you can use with the object $object For example, for the payment deadline you will find in this file the following line: var $date_lim_reglement; To use it add to your substitution table

$formmail->substit['__FACDATELIMREG__']=date('d/m/Y',$object->date_lim_reglement);