CakePHP 4: Sending email from CLI can not create full URL Link

Dear all,

I am sending emails from the same template and template variables, one of that is entity ID for creating View link.

  • If using direct email sending from web app controller, the link has full URL.
  • If using MailQueue which sends email via CLI command, the link does not have full URL, only controller, action, and parameter (entity ID).

Is it supposed to work that way?

When running in the web app context, there are $_SERVER variables that Cake accesses to understand what domain you are on. When running from the CLI, these don’t exist. This is what the App.fullBaseUrl setting is for.

Thank you a lot, Zuluru

thanks for the awesome information.

Note that App.fullBaseUrl can also be useful in web context, if you have multiple domains that your app runs under, but you want all emails that go out to reference a “primary” one regardless of which one the user is on when the email is triggered.