# Set up emails and easy email delivery

**URL:** https://discuss.tryton.org/t/set-up-emails-and-easy-email-delivery/2116
**Category:** Ideas
**Created:** [December 26, 2019, 11:40am UTC](https://discuss.tryton.org/t/set-up-emails-and-easy-email-delivery/2116 "2019-12-26T11:40:10Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![osloar](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/osloar/32/599_2.png) [@osloar](https://discuss.tryton.org/u/osloar)
#### Post date: [December 26, 2019, 11:40am UTC](https://discuss.tryton.org/t/set-up-emails-and-easy-email-delivery/2116/1 "2019-12-26T11:40:10Z")

</div>

Hello, I wanted to raise a situation that I find very usual.

One of the problems I am encountering with tryton is the difficulty in setting up email accounts and being able to send from the application.

These difficulties are as follows:

1st: Difficulty for the client to enter the user, pwd, smtp server, port, of his email account (since many times they do not want to provide the information).

2nd: Be able to make promotions or mailings easily. The marketing module is a good idea but I think it is difficult to manage for a user.

3rd: In order to send emails from an Invoice, Sales … can only be performed by the action of a button such as accounting, process, … and not always have to be this way, since the client The best you need to send a text in the same mail.

The solutions or proposals are:

1st: Create a configuration screen where the client puts the data of his email account (user: pwd: smtp, …)

2nd: For us the marketing module should be easy to select the emails create a content and schedule / send.

3rd: On the print button, apart from the reports, you could show an action that is sent by email and that a form appears with the client’s email account and a description field where you can put what you want.

I hope I don’t bother with these ideas.

Thank you

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [December 26, 2019, 12:30pm UTC](https://discuss.tryton.org/t/set-up-emails-and-easy-email-delivery/2116/2 "2019-12-26T12:30:42Z")

</div>

So basically, you request to change the client into a [mail user agent](https://en.wikipedia.org/wiki/Email_client). I do not think it gonna happen because developing a MUA is a project as big (and maybe bigger) than Tryton.

> [@osloar](#):
>
> Difficulty for the client to enter the user, pwd, smtp server, port, of his email account

It is not the user email account that Tryton needs but a dedicated email account for him to send email as the ERP.

> [@osloar](#):
>
> Be able to make promotions or mailings easily. The marketing module is a good idea but I think it is difficult to manage for a user.

Please make comments if you have some on [https://codereview.tryton.org/38711002](https://codereview.tryton.org/38711002) before it will be included.  
For me, it is very close to an usual MUA (but simplified). But of course new feature could be added like the possibility to upload images etc.

> [@osloar](#):
>
> On the print button, apart from the reports, you could show an action that is sent by email and that a form appears with the client’s email account and a description field where you can put what you want.

I guess we could display a confirmation dialog box in mailto command before calling the “mailto”. It will display the parameters: `to`, `cc`, `subject` and `body`.  
But normally, the email client should already have this confirmation window?

For the web client, the email report option is not yet implemented but it should be possible using a `mailto` URI.

---

<div class="post-metadata">

### Author: ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)
#### Post date: [December 26, 2019, 1:06pm UTC](https://discuss.tryton.org/t/set-up-emails-and-easy-email-delivery/2116/3 "2019-12-26T13:06:56Z")

</div>

> [@osloar](#):
>
> 3rd: On the print button, apart from the reports, you could show an action that is sent by email and that a form appears with the client’s email account and a description field where you can put what you want.

With the Tryton client you can use the “Email report” button to create a report, open your default email-client and fill the different fields. The report is attached with the email.

> [@ced](#):
>
> > Difficulty for the client to enter the user, pwd, smtp server, port, of his email account
> 
> It is not the user email account that Tryton needs but a dedicated email account for him to send email as the ERP.

I think it could be possible to add those parameters to the user preferences. eventually username and password are needed. The rest is like server etc are general parameters and configured in the config file.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [December 26, 2019, 1:51pm UTC](https://discuss.tryton.org/t/set-up-emails-and-easy-email-delivery/2116/4 "2019-12-26T13:51:39Z")

</div>

> [@edbo](#):
>
> I think it could be possible to add those parameters to the user preferences.

For what purpose? It is better that those parameters stay in the MUA and that the MUA send the email as usually it will store a copy in the mailbox.

---

<div class="post-metadata">

### Author: ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)
#### Post date: [December 26, 2019, 2:18pm UTC](https://discuss.tryton.org/t/set-up-emails-and-easy-email-delivery/2116/5 "2019-12-26T14:18:08Z")

</div>

> [@ced](#):
>
> For what purpose? It is better that those parameters stay in the MUA and that the MUA send the email as usually it will store a copy in the mailbox.

I completely agree with you. It’s more about Tryton itself instead of the client. Because you are able to send emails from Tryton using `smtpdatamanager`.  
Looking at my own situation and there I need a username and password to be able to send an email. You can use the defaults from the configuration file like the `from` and the smtp server location. But maybe sometimes you want to use the email address configured for the user in Tryton. For example you can do so with `account_dunning_email`, but in my case I need also an password to send the email. The username is the same as the email address. Also you want to use different email addresses for the different parts (marketing, invoice, dunning etc). I know maybe not the best example.

So in short. If you want to send email from Tryton automatically like `account_dunning_email` you use the defaults from the config file. But now you want to use the email address from the user logged in, so replies on that email comes into the right mailbox. In some cases a password is needed to send an email. Username is mostly configured as email address.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [December 26, 2019, 3:00pm UTC](https://discuss.tryton.org/t/set-up-emails-and-easy-email-delivery/2116/6 "2019-12-26T15:00:26Z")

</div>

Well you do not need to setup this in Tryton itself. There are many options:

- Use a different from header than the envelop.
- Set a `Reply-To` header.
- Configure the SMTP server to allow “tryton” user to send with different from envelop.
- Configure the SMTP server to forward to the proper email server using the login/password of the from address.

I would recommend [OpenSMTPD](https://opensmtpd.org/) as mail server for such configuration because the configuration is very simple and clear.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [December 26, 2019, 3:35pm UTC](https://discuss.tryton.org/t/set-up-emails-and-easy-email-delivery/2116/7 "2019-12-26T15:35:30Z")

</div>

On a second though, I think we could get rid of the “mailto” and have a dedicated dialog box for sending email via the Tryton server. As long as we use the `On-Behalf-Of` (and `Repl-To`) as explained in [https://stackoverflow.com/questions/2782380/best-practices-sending-email-on-behalf-of-users](https://stackoverflow.com/questions/2782380/best-practices-sending-email-on-behalf-of-users).

So for me, the dialog would be:

- `To`: filled with the report `to` value by default and with auto-completion using the contact mechanism. It is a comma separated list of addresses (maybe formatted with the party name).
- `Cc` and `Bcc`: optional but behave like `To`
- `Subject`: filled with report default
- `Message`: the body from report by default with the user signature append after `'-- '`. The widget will use the richtext as it is HTML compatible.
- `Template`: a list is existing template if selected fill the message content using the value of the record. Available only if a single record is selected.
- Options as checkbox: “Send me a copy” (add the user as Bcc), [“Request read receipt”](https://tools.ietf.org/html/rfc3798), etc.
- List of attachments: with the report by default. It can be edited by adding, removing and change the name.

When send is clicked, the client request the server to send it on behave of the user. The server send it directly in order to generate an error message.

---

<div class="post-metadata">

### Author: ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)
#### Post date: [December 27, 2019, 10:09am UTC](https://discuss.tryton.org/t/set-up-emails-and-easy-email-delivery/2116/8 "2019-12-27T10:09:55Z")

</div>

> [@ced](#):
>
> As long as we use the `On-Behalf-Of` (and `Repl-To` ) as explained in [https://stackoverflow.com/questions/2782380/best-practices-sending-email-on-behalf-of-users](https://stackoverflow.com/questions/2782380/best-practices-sending-email-on-behalf-of-users).

In the same thread (9 years old, last post in 2018) they advice not to use the `on-behalf-of` because of getting trapped by spam filters. Or even completely banned by mail providers because of phishing attacks. It will work within the company, but outside it is questioned. Also I’ve only seen it within companies where a secretary is sending an email `on-behalf-of` a manager, mostly an meeting request.

If it is possible, add a `From:` in the dialog as well. The user can select it’s own email address or the default configured in the config file. Tryton will use the `From:` email address and if not the same as the users email address Tryton adds the `Reply-To:` to the email header.

It’s the responsibility of the admin user to setup the mail correctly.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [December 27, 2019, 11:17am UTC](https://discuss.tryton.org/t/set-up-emails-and-easy-email-delivery/2116/9 "2019-12-27T11:17:25Z")

</div>

> [@edbo](#):
>
> The user can select it’s own email address or the default configured in the config file. Tryton will use the `From:` email address and if not the same as the users email address Tryton adds the `Reply-To:` to the email header.

I made some tests by sending such emails from my [b2ck.com](http://b2ck.com) address to a [gmail.com](http://gmail.com) (as they manage a very large portion of the email and they are defacto the standard others follow).  
The `On-Behalf-Of` is indeed to use the `From` and `Sender` header. In the `From`, we put the “user address” and in `Sender` the “Tryton address”.  
In such case, Gmail shows correctly that the email is from the “user address” but was send via “Tryton address” domain. The email is not put in the Spam. This is if the “user address” domain does not have DMARC setup.  
Now if I do the same with a “user address” domain setup with DMARC which does not allow the “Tryton address” domain to send them. Then those email goes to the Spam folder (because the DMARC policy was quarantine. This is because the “From” is part of the DKIM headers. The same applies to wrong SPF configuration of course.

It works as expected but people need to know how to configure email servers to have a correct behavior.  
So I think the default behavior should be to use “Tryton address” as `From` and add `Reply-To`. But we must have a configuration flag that allow to activate the “User address” as `From` with “Tryton address” as `Sender` and no `Reply-To` for the setup which are correctly configured.

---

<div class="post-metadata">

### Author: ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)
#### Post date: [December 27, 2019, 12:35pm UTC](https://discuss.tryton.org/t/set-up-emails-and-easy-email-delivery/2116/10 "2019-12-27T12:35:25Z")

</div>

> [@ced](#):
>
> So I think the default behavior should be to use “Tryton address” as `From` and add `Reply-To` .

You very often see this kind of behavior. The email is send from a `noreply@domain.com` and then there is a `Reply-To:` in the header or there is a reply email address (mailto) in the message body where a user can click on to reply on the email.

To make things more complex 🙂 Mostly the `Reply-To:` is an email alias. So when a company sends an invoice by email, the `From:` will be `noreply@domain.com`, the `Reply-To:` will be e.g. `invoice@domain.com`. So multiple users gets your reply in their mailboxes. Maybe in Tryton this email addresses can be added on groups? So users who are in that group can fill the `Reply-To:` also with that email address.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [December 27, 2019, 12:40pm UTC](https://discuss.tryton.org/t/set-up-emails-and-easy-email-delivery/2116/11 "2019-12-27T12:40:00Z")

</div>

> [@edbo](#):
>
> So when a company sends an invoice by email, the `From:` will be `noreply@domain.com` , the `Reply-To:` will be e.g. `invoice@domain.com` .

This is not part of this topic. Here we are talking about user sending a report to someone which may lead to a conversation.  
Invoice delivery is a different topic which is already managed by the `notification_email` module.

---

<div class="post-metadata">

### Author: ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)
#### Post date: [December 27, 2019, 1:04pm UTC](https://discuss.tryton.org/t/set-up-emails-and-easy-email-delivery/2116/12 "2019-12-27T13:04:23Z")

</div>

It was an example, replace `invoice` by `report`. IMO this is about **manually** sending any kind of report (sale, purchase, invoice, marketing, dunning, …). The `notification_email` is **automatically** sending reports.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [December 27, 2019, 3:25pm UTC](https://discuss.tryton.org/t/set-up-emails-and-easy-email-delivery/2116/13 "2019-12-27T15:25:08Z")

</div>

Well I guess extra headers would be configurable like “Cc”, “Bcc” etc. And so “Reply-To” could also be added.  
I think as it is for experienced users, it would be hidden behind a expandable option (like the CSV options).

---

<div class="post-metadata">

### Author: ![SISalp](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/sisalp/32/200_2.png) [@SISalp](https://discuss.tryton.org/u/SISalp)
#### Post date: [May 6, 2020, 10:31am UTC](https://discuss.tryton.org/t/set-up-emails-and-easy-email-delivery/2116/14 "2020-05-06T10:31:38Z")

</div>

I think we may not need the dialog box if configuration is complemented.

> [@ced](#):
>
> So for me, the dialog would be:
> 
> - `To` : filled with the report `to` value by default and with auto-completion using the contact mechanism. It is a comma separated list of addresses (maybe formatted with the party name).
> - `Cc` and `Bcc` : optional but behave like `To`

Couldn’t we manage all this in party’s contacts ? A “To” for invoice and a “To” for sale etc…

> [@ced](#):
>
> - `Subject` : filled with report default

Would be good if it can be specific : “Your new invoice N XXXX”

> [@ced](#):
>
> - `Message` : the body from report by default with the user signature append after `'-- '` . The widget will use the richtext as it is HTML compatible.

If we use a template, it can include contact instructions like a signature.

> [@ced](#):
>
> - `Template` : a list is existing template if selected fill the message content using the value of the record. Available only if a single record is selected.

If we use a single template, we may use “IF” clause in it so the content of the message follows the same rules than the document.

> [@ced](#):
>
> - Options as checkbox: “Send me a copy” (add the user as Bcc), [“Request read receipt”](https://tools.ietf.org/html/rfc3798), etc.

I would prefer this to be defined at template level, rather than by the user.

> [@ced](#):
>
> - List of attachments: with the report by default. It can be edited by adding, removing and change the name.

I would prefer not to have this capability

> [@ced](#):
>
> When send is clicked, the client request the server to send it on behave of the user. The server send it directly in order to generate an error message.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [May 6, 2020, 1:00pm UTC](https://discuss.tryton.org/t/set-up-emails-and-easy-email-delivery/2116/15 "2020-05-06T13:00:51Z")

</div>

> [@SISalp](#):
>
> I think we may not need the dialog box if configuration is complemented.

I do not think we can avoid the dialog box. The goal is to let the user customize the default values for example to add a comment or to attach a new document.  
Otherwise it is the `notification_email` module that manage to define sending automatically emails.

> [@SISalp](#):
>
> Couldn’t we manage all this in party’s contacts ? A “To” for invoice and a “To” for sale etc…

We will present a default value per report but user will be free to send to any one.

> [@SISalp](#):
>
> Would be good if it can be specific : “Your new invoice N XXXX”

That your own choice. This will be defined on the report and can be customized.

> [@SISalp](#):
>
> If we use a template, it can include contact instructions like a signature.

For me, there is no need to repeat the signature appending on all the templates. This can be done automatically and correctly (I mean using correct signature standard).

> [@SISalp](#):
>
> If we use a single template, we may use “IF” clause in it so the content of the message follows the same rules than the document.

I would like to avoid templates with conditional clause because it will make them no more editable using the UI (Genshi clauses must be encoding on raw text).  
Also this makes them harder to ensure correctness as each possible branches should be tested etc.  
So for me, we should keep it simple using simple Python format syntax.  
The _IF_ clauses could be managed by creating multiple format and we could imagine to extend later the format to define condition to be used per record.

> [@SISalp](#):
>
> I would prefer this to be defined at template level, rather than by the user.

This is clearly a user choice to receive a copy or not.

---

<div class="post-metadata">

### Author: ![SISalp](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/sisalp/32/200_2.png) [@SISalp](https://discuss.tryton.org/u/SISalp)
#### Post date: [May 6, 2020, 1:05pm UTC](https://discuss.tryton.org/t/set-up-emails-and-easy-email-delivery/2116/16 "2020-05-06T13:05:03Z")

</div>

So probably I need more a flexibility degree on `notification_email` module rather than a true email module.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [June 30, 2020, 3:30pm UTC](https://discuss.tryton.org/t/set-up-emails-and-easy-email-delivery/2116/18 "2020-06-30T15:30:31Z")

</div>

I created [Send client email via server (#9449) · Issues · Tryton / Tryton · GitLab](https://bugs.tryton.org/issue9449) which is still work in progress (missing completion and sao version).
