Sending emails not working after upgrade from 5.3 to 6.2

Silverstripe Version: 6.2

Has anything been changed between SS5.3 and 6.2 that emails don’t work anymore?

I upgraded a website from 5.3 to 6.2 and now on version 6.2 neither the forgot password link email nor the “from” email under ‘Recepient’ on an User Defined Form page work.

Emails don’t get send and I can’t find anything in a log file.

MX record is domain.mail.protection.outlook.com and the domain is an add-on domain on the server, Not sure if any of this is now on 6.2 relevant.

Any hint would be great. Thanks.

There were significant changes in the underlying email code in CMS 6.

You’ll want to configure a mailer DSN string in your environment, eg:

MAILER_DSN=“smtp://user:pass@smtp.example.com:1234”

See here for full details:

Hi Tim,

Thank you for your reply. I saw this documentation but it didn’t make sense to me (a real world example for e.g. outlook is missing for me to understand how to really configure this). Then I couldn’t really believe that I have to enter my password here. So, I thought that can’t be right I misunderstand something here.

Do I really have to put my email password into this? Why did SilverStripe change to this? So every admin can go, have a look and log into my email account or is there anything I am missing?

What if my email is 2-factor-authorised? How would that work?

Why did it work out of the box before and now such a dramatic change?

Hi,

How were you sending emails in CMS 5? Did you not have a username and password there?

Are you using a personal email account for sending emails from the site?

The change to Symfony mailer under the hood provides better ongoing support and actually allows more flexibility in different ways to send.

The DNS lives in the environment, so yes, it would be visible to anyone with server access… but if you can’t trust those people with security details, I’d say you have bigger concerns,

Hi Tim,

In CMS 5 I didn’t use username and password.

There was this Swift_Transport class Swift_SendmailTransport used in the config.

It is a domain email that my client want to send those emails from.

I partly solved it by setting a SS_SEND_ALL_EMAILS_FROM so the forgot password works, but they actually wanted the “from” email under Recipients in the UserDefinedForm page to work.

I’m still not entirely clear how you were sending email before the upgrade. If not with SMTP, then what was the mechanism? How was it configured?

There was an email.yaml file with the following content:

# See https://docs.silverstripe.org/en/4/developer_guides/email/ for additional information about setting up email

---

Name: project-emailconfig

After:

  - '#emailconfig'

---

SilverStripe\Core\Injector\Injector:

  Swift_Transport:

    class: Swift_SendmailTransport

Right… got you.

That’s using sendmail on the server (which presumably has all the relevant routing, etc. in place to make emails work).

So, if you just remove the MAILER_DSN from your environment (if you put one in) the default behaviour in CMS6 is to also use sendmail.

I think I may have actually misunderstood the issue you’re having.

So, if you remove the SEND_ALL_EMAILS_FROM env, are you saying that no emails are being sent/delivered?

Do you have the default admin email address set in yml?

SilverStripe\Control\Email\Email:
  admin_email: support@example.com

If so, that should allow things like password resets to work.

In your user defined form, are you setting the ‘From’ field in the recipients tab, or the ‘Reply to’ field and choosing the email field from the dropdown?