Go to page content

Sending mail: the sender’s domain

Setting your e-mail bounce/sender domain and fixing domain errors when sending e-mail.

Why

Recipients of e-mail want a valid sender’s address on the envelop. This describes how to configure your e-mail sender domain.

Assumptions

Zotonic 0.7 and later. This version introduced a built-in smtp server and client.

How

You have to think of e-mail as normal snail mail. There is a message and an envelop.

The email_from is the address that is written on the message.  It could be anything and is generally not used when delivering your mail. The postman only looks on the envelop!

The address on the envelop is the most important address. It is where your e-mail is returned to when the message can‘t be delivered (so called bounces). Often it is also checked for validity when the e-mail is delivered at a SMTP server.

You need a valid domain for this envelop sender address. The part before the @ is generated by Zotonic and is used for identifying the original message and recipient when the message bounces.

How does Zotonic know the domain?

It checks in order:

  • zotonic priv/config: smtp_bounce_domain
  • site's config: smtphost  (you can also set this with the admin config as site.smtphost)
  • site's config: hostname
And then adds the part before the @.  
A typical sender address on the envelop looks like: noreply+mlcm6godbz2cchtgdvom@example.org

Troubleshooting

Check in the admin the log and smtp log. When a message bounces then you will see errors there.

A typical error looks like:

SMTP: bounce: 504 5.5.2 <noreply+mlcm6godbz2cchtgdvom@oeps>: Sender address rejected: need fully-qualified address To: piet@example.com (1234) From: <noreply+mlcm6godbz2cchtgdvom@oeps>

This page is part of the Zotonic documentation, which is licensed under the Apache License 2.0.