I am sending an e-mail using one of our Microsoft 365 accounts. The account has the following configuration set on MS365:
- Display name:
this should not be displayed
- e-mail:
[email protected]
In my code, I am trying to send an e-mail using [email protected]
(which is ok to be displayed) but instead of showing the account's default display name, I want it to say "Some content relevant name
".
When using this example code:
<?php
$transport = (new Swift_SmtpTransport('smtp.office365.com', 587, 'tls'))
->setUsername('your username')
->setPassword('your password');
$mailer = new Swift_Mailer($transport);
$message = (new Swift_Message('Wonderful Subject'))
->setFrom(['[email protected]' => 'Some content relevant name'])
->setBody('Here is the message itself');
$result = $mailer->send($message);
The e-mails arrive with the display name this should not be displayed
instead.
How can I set a custom display name when sending emails with MS365 SMTP?
CodePudding user response:
Error on my side, the custom display name works for everybody outside of the organization.