Setting the "From" email address

This is just an informative post for an issue I came across today regarding the “From” email address. I know others have had this issue in the past, but I think the most recent post is over a year old so I can’t reply to it anymore.

In Omeka S, system emails typically come from the Administrator email set in the Global Settings (as mentioned in the post linked above).

In our case, we don’t want the From address to be the Administrator email address. This is because we use an email service to send emails tied to the Omeka S domain that has DKIM and SPF configured and is not the same as the Administrator email domain. I could go into more detail on this if anyone is interested.

An example use case is the Contact Us module which will now send notifications to the Administrator email address (user@gmail.com) from our email service provider address (noreply@our-omeka-s-domain.org).

To accomplish this, we have configured the mail key in the local.config.php file and additionally added the undocumented default_message_options key:

'mail' => [
        'default_message_options' => [
            'from' => 'noreply@our-omeka-s-domain.org',
        ],
        'transport' => [
            'type' => 'smtp',
            'options' => [
                ...
            ],
        ],
    ],

This allows Administrators to receive system notifications while also ensuring excellent email deliverability.

This will work on Omeka S 3.0 and up.

I’d quibble slightly with the “undocumented” nature of that config key, but ultimately the information given is a not-terribly-clear reference to the Laminas docs; the context there is that for everything that the Laminas “Message” class has a setter for, that can be set in default_message_options. Though of course some things like body, etc. would be overwritten if set as a default in that way.

I really don’t mind if you object. I was just trying to share something that wasn’t clear to me at first and took a little digging to discover.

I hope other people find this explanation helpful.