But I don’t know how to set the SMTP profile to activate.
I have custom send message an email as follows:
use Cake\Mailer\Message;
use Cake\Mailer\Transport\MailTransport;
$message = new Message;
$message
->setCharset('utf-8')
->setHeaderCharset('utf-8')
->setSubject('subject')
->setBodyHtml('body');
$transport = new MailTransport;
$transport->send($message);
The documentation also mentions “configuration profiles”, which it seems might let you set this for all emails instead of one at a time, but it’s not clear to me exactly how this works.
It’s great if that works for you, but it’s a limited solution. It’s not necessarily portable to other server setups, and it’s not unit-test friendly. If you don’t care about those things, then it’s fine.
That’s just weird. Both of these things should set who the email is from, one or the other should be sufficient. email@email.com is obviously not the actual address you’re using. Is there any chance that Cake is rejecting the actual email address as having an invalid format?
This is not a real address. I also forgot to write that the email will not arrive, especially to the email within the hosting email@email.com> email@email.com, but for example email@email.com> something@gmail.com will arrive. I tried another domain and it didn’t arrive either … so it’s not 100% sure that the email will get where I need it. CAKE does not return any error. But with the -f parameter, it now delivers everywhere.
Wait, what are the ">"s in here? Are you using a mailto link for the email address instead of just the email address? Or passing in a single string that contains both the email address and the name?
Well then, I’d start looking into the specifics of the email that gets generated (e.g. with a debugger or the like), to see if Cake is correctly setting the From details on the outgoing email without the -f option. If it isn’t debug why not. If it is, maybe the problem is something in your localhost SMTP server setup; you’re connecting to it without any username and password, it seems, which many servers will treat differently.