# Imposta l'indirizzo email del mittente in Discourse

**URL:** https://meta.discourse.org/t/set-sender-from-email-address-in-discourse/111643
**Category:** Support
**Created:** [15 Marzo 2019, 1:28am UTC](https://meta.discourse.org/t/set-sender-from-email-address-in-discourse/111643 "2019-03-15T01:28:40Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![sebastien](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@sebastien](https://meta.discourse.org/u/sebastien)
#### Post date: [15 Marzo 2019, 1:28am UTC](https://meta.discourse.org/t/set-sender-from-email-address-in-discourse/111643/1 "2019-03-15T01:28:40Z")

</div>

Hi,

We are experiencing an interesting problem with discourse + mailgun.

Our email domain (@something.com) does not match the subdomain we are using in mailgun ([mg.something.com](http://mg.something.com)). As a result all emails are sent as

> [noreply=something.com@mg.something.com](mailto:noreply=something.com@mg.something.com); on behalf of; My Community [noreply@something.com](mailto:noreply@something.com)

This **may** be caused by the Sender not being set by discourse. In the email’s headers I can see that  
`[Sender]: noreply=something.com@mg.something.com`

Both my email notification and email site title are set. Is there a way to force the sender=email notification in Discourse (latest version)?

Thx  
Sebastien

---

<div class="post-metadata">

### Author: ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)
#### Post date: [15 Marzo 2019, 7:52am UTC](https://meta.discourse.org/t/set-sender-from-email-address-in-discourse/111643/2 "2019-03-15T07:52:09Z")

</div>

You need to check the `notification_email` setting to match `noreply@mg.example.com`

---

<div class="post-metadata">

### Author: ![sebastien](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@sebastien](https://meta.discourse.org/u/sebastien)
#### Post date: [15 Marzo 2019, 9:27am UTC](https://meta.discourse.org/t/set-sender-from-email-address-in-discourse/111643/3 "2019-03-15T09:27:43Z")

</div>

We do not want to expose this subdomain to our users. Mailgun recommends the usage of subdomains when sending mails. The idea would be to force the sender headers in discourse. According to our test, it seems to work well.

Would it be possible to do that in discourse?

---

<div class="post-metadata">

### Author: ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)
#### Post date: [15 Marzo 2019, 9:34am UTC](https://meta.discourse.org/t/set-sender-from-email-address-in-discourse/111643/4 "2019-03-15T09:34:13Z")

</div>

Contact mailgun for help.

In my experience using domain while verifying subdomain makes emails end up in spam.

---

<div class="post-metadata">

### Author: ![sebastien](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@sebastien](https://meta.discourse.org/u/sebastien)
#### Post date: [19 Marzo 2019, 7:50am UTC](https://meta.discourse.org/t/set-sender-from-email-address-in-discourse/111643/5 "2019-03-19T07:50:25Z")

</div>

This is the comment from my network manager.

I’ve been working with all our email systems, both internal and external, and also SPF, DKIM and DMARC setups -

For many of our providers, we are allowed to send through mailgun, as `mg.example.com` subdomain, but the sender and from fields are set to match `@example.com` - so there is no “on behalf of” issue.

For dmarc alignment, the really important parameter is the “d=” field when signing the email with dkim. If this is `d=example.com`, then everything is aligned because the `@example.com` is matching the top level sender domain (ie, `outdomain.com`) - so the mechanisms “SPF dmarc alignment” and “DKIM dmarc alignment” both show as “pass”. When eveything shows as pass, the email is accepted as valid.

So, we have a couple issues here. Can we set the “sender” and “from” fields?

Do you properly assign the domain in the “d=” when dkim signing the email?

---

<div class="post-metadata">

### Author: ![c0ry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/c0ry/32/134424_2.png) [@c0ry](https://meta.discourse.org/u/c0ry)
#### Post date: [19 Marzo 2019, 8:07am UTC](https://meta.discourse.org/t/set-sender-from-email-address-in-discourse/111643/6 "2019-03-19T08:07:21Z")

</div>

In your settings, you can setup the domain to point to whatever domain you want.  
My site is hosted on [board.example.com](http://board.example.com) and the emails come from [example.com](http://example.com)

Is that what you mean?

---

<div class="post-metadata">

### Author: ![sebastien](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@sebastien](https://meta.discourse.org/u/sebastien)
#### Post date: [19 Marzo 2019, 8:13am UTC](https://meta.discourse.org/t/set-sender-from-email-address-in-discourse/111643/7 "2019-03-19T08:13:11Z")

</div>

here it’s not related to the website url but to the SMTP Domain vs Sender domain.  
Our smtp is `mg.something.com` whereas our sender domain is `something.com`.

---

<div class="post-metadata">

### Author: ![c0ry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/c0ry/32/134424_2.png) [@c0ry](https://meta.discourse.org/u/c0ry)
#### Post date: [19 Marzo 2019, 8:17am UTC](https://meta.discourse.org/t/set-sender-from-email-address-in-discourse/111643/8 "2019-03-19T08:17:31Z")

</div>

My mailgun is setup as mg.example as well. Still uses [example.com](http://example.com) as the protocol.  
**edit** maybe I’m just not understanding what you’re trying to imply.  
Apologies.

---

<div class="post-metadata">

### Author: ![sebastien](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@sebastien](https://meta.discourse.org/u/sebastien)
#### Post date: [19 Marzo 2019, 8:20am UTC](https://meta.discourse.org/t/set-sender-from-email-address-in-discourse/111643/9 "2019-03-19T08:20:54Z")

</div>

Interesting. Do you receive email with sender displayed as  
[noreply=something.com@mg.something.com](mailto:noreply=something.com@mg.something.com); on behalf of; My Community [noreply@something.com](mailto:noreply@something.com)

---

<div class="post-metadata">

### Author: ![jason1](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@jason1](https://meta.discourse.org/u/jason1)
#### Post date: [19 Marzo 2019, 8:35am UTC](https://meta.discourse.org/t/set-sender-from-email-address-in-discourse/111643/10 "2019-03-19T08:35:45Z")

</div>

c0ry, it seems we are not able to set the “sender” and “from” (and the “return path”) fields to be the same. If they are not the same, you can get emails that say “sent on behalf of”. Then risk of spam classification is higher.

---

<div class="post-metadata">

### Author: ![Simon\_H](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon_h/32/187594_2.png) [@Simon\_H](https://meta.discourse.org/u/Simon_H)
#### Post date: [21 Luglio 2020, 12:53pm UTC](https://meta.discourse.org/t/set-sender-from-email-address-in-discourse/111643/11 "2020-07-21T12:53:52Z")

</div>

Sto lottando con l’integrazione delle email in uscita con Office365.  
Ci sono diversi thread che discutono di problemi relativi alle email.  
Per informazione:  
Di default, Office365 restituisce un errore 554 se il mittente non corrisponde all’account di accesso (e i log di Discourse non sono molto dettagliati).

L’indirizzo del mittente può essere impostato, come discusso altrove, utilizzando:  
rails r “SiteSetting.notification\_email = ‘discourse@yoursite.com’”

Ma credo che questo imposti solo la prima email inviata.

Nota: l’URL del mio forum NON è correlato al dominio della mia email…  
Nel mio caso, ho dovuto impostare quanto segue nelle impostazioni (GUI):  
1/ email di notifica  
2/ nome utente del contatto del sito: questo significa che DEVI avere un utente con l’email da cui desideri inviare (cioè l’email con cui accedi a SMTP).

In pratica, TUTTE le email inviate da Discourse devono avere il campo ‘from’ impostato sulla stessa email utilizzata per l’accesso SMTP, per utilizzare una connessione SMTP ‘normale’ di Office365. Spero che quanto sopra riesca a ottenere questo risultato, ma sarebbe un’ottima funzionalità poter impostare in modo definitivo il campo ‘from’ per ogni email, con garanzia.

s
