Upgrade Guide to Mail Core 6.0

Make sure to read updating Mail Core for general information about updating Mail Core in general. If you have an older version of mail core in your app, and need to update to 6.0, here are the specific changes needed for this update:

In your apps config/app.php:

  • Add mail-core.sender.name to your app.php. It should be set to your app name then "Notifications". For example, "Service Stats Notifications" (See Setup for more details)
  • Remove any default email config

In your app’s server side logic:

  • Find all instances of inject('mailer')
  • If your from address uses a default email (substitutions, tally):
  • Instead of setFrom($appEmail, $appName), use setConfigFrom(). This automatically sets both values from config
  • Remove the line that fetches the default config email address If your address uses the user’s email and name to send the notification (service stats, status):
  • Instead of setFrom($userEmail, $username), use setConfigFrom($username). This automatically set the address from the config, but uses the custom name as the from name
  • Add addReplyTo($userEmail, $username) . This makes it so clicking reply replies to that address like before. Good idea to validate that $userEmail is not empty or null.

Exception handling:

  • If the only purpose of your route is to send an email, replace send() with send(true) So it throws exceptions. By default send() or send(false) now catch errors and writes them to the log, but for email only routes its a good idea to still throw
  • If you surround your email code with try/catch to catch errors, you can remove those blocks. This handles it internally.
  • If you send multiple emails in a loop, note send returns a boolean based on if it is successful, so you can break on false

For examples, see the following commits: