# SMTP 通过错误的主机发送电子邮件

**URL:** https://meta.discourse.org/t/smtp-email-sending-from-wrong-host/68347
**Category:** Support
**Created:** [2017年八月18日 22:56 UTC](https://meta.discourse.org/t/smtp-email-sending-from-wrong-host/68347 "2017-08-18T22:56:03Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![frostyfrog](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/frostyfrog/32/120808_2.png) [@frostyfrog](https://meta.discourse.org/u/frostyfrog)
#### Post date: [2017年八月18日 22:56 UTC](https://meta.discourse.org/t/smtp-email-sending-from-wrong-host/68347/1 "2017-08-18T22:56:03Z")

</div>

I’ve looked at the configs and I can’t figure out how to change the host that email is being sent from, other than changing the `DISCOURSE_HOSTNAME` variable. However, based on the comments, If I change that to say… example(dot)com, then if I visit VPS.provider.example(dot)com, I will no longer see the discourse service.

Alrighty, let’s see if I can make that a bit clearer now… (my real domain is replaced with [example.com](http://example.com))

- My VPS hosting discourse is on a different machine than my email server (due to the fact that I don’t trust the discourse-setup and launcher scripts being run as root).
- My email server serves email from example(dot)com
- Discourse is running on myvps.do.example(dot)com
- Discourse is logging into smtp.example(dot)com to send emails
- Discourse is sending emails from noreply@myvps.do.example(dot)com
- Google receives the email and throws it away due to strict SPF and DKIM rules
- Google sends me an email of said rejection by the next day via the DMARC system

I’m not sure what I can do to fix this, is there anyway to change the sending address? (I’ll be taking a look into spoofing the [header.from=myvps.do.example.com](http://header.from=myvps.do.example.com) from the postfix side to see if that helps at all) I’m able to login to the system since I can send emails to example(dot)com and be just fine, but sending to other email providers is another story.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2017年八月18日 23:02 UTC](https://meta.discourse.org/t/smtp-email-sending-from-wrong-host/68347/2 "2017-08-18T23:02:00Z")

</div>

There is a commented line at the bottom of app.yml that will change the sending address. Just edit it with your address and rebuild.

---

<div class="post-metadata">

### Author: ![frostyfrog](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/frostyfrog/32/120808_2.png) [@frostyfrog](https://meta.discourse.org/u/frostyfrog)
#### Post date: [2017年八月19日 02:18 UTC](https://meta.discourse.org/t/smtp-email-sending-from-wrong-host/68347/3 "2017-08-19T02:18:31Z")

</div>

Alright, thanks. I must’ve missed it since it wasn’t in the same place as the other SMTP settings. 😕

---

<div class="post-metadata">

### Author: ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)
#### Post date: [2017年八月19日 06:49 UTC](https://meta.discourse.org/t/smtp-email-sending-from-wrong-host/68347/4 "2017-08-19T06:49:26Z")

</div>

It’s a bit tricky because the other settings are all passed by environment (needed on every container start-up), but that one is a database edit (needed only once ever).

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [2024年六月8日 12:44 UTC](https://meta.discourse.org/t/smtp-email-sending-from-wrong-host/68347/5 "2024-06-08T12:44:23Z")

</div>

此主题已在 2485 天后自动关闭。不再允许回复。
