Lost password error: Cannot send message without a sender address

Silverstripe Version:
4.0.2.

Question:
I´ve configured SwiftMailer for sending status-mails like it is described here:
https://docs.silverstripe.org/en/4/developer_guides/email/

Everything works fine except the lost password function. If you want to reset your password this error appears:

[Emergency] Uncaught Swift_TransportException: Cannot send message without a sender address

In my _config folder I have this email.yml:

---
Name: myemailconfig
After:
  - '#emailconfig'
---
SilverStripe\Core\Injector\Injector:
  Swift_Transport:
    class: Swift_SmtpTransport
    properties:
      Host: ###myHost###
      Port: 587
      Encryption: tls
    calls:
      Username: [ setUsername, ['###myUser####'] ]
      Password: [ setPassword, ['###myPassword###'] ]
      AuthMode: [ setAuthMode, ['login'] ]

And I tried to set email configurations in the .env file:

MAIL_DRIVER=smtp
MAIL_HOST=###myHost###
MAIL_PORT=587
MAIL_USERNAME= ###myUser####
MAIL_PASSWORD= ###myPassword###
MAIL_ENCRYPTION=tls

Any idea how to fix this?

Have you tried setting the admin email address for the system?

You can do this either in yml: Email – SilverStripe Documentation

Or via a .env variable: Environment Management – SilverStripe Documentation

2 Likes

Great, thanks! I have added this to my env-file:

SS_SEND_ALL_EMAILS_FROM="###myEmail###"

This solve the problem!