I have a contact form in Symfony 7 which sends an email in my contact controller:
use SymfonyComponentMailerMailerInterface;
public function __construct(private readonly MailerInterface $mailer)
$email = (new Email())
->from(new Address('[email protected]', strip_tags($form->get('name')->getData())))
->replyTo($form->get('email')->getData())
->to('[email protected]')
->subject('Test')
->html($form->get('message')->getData());
$this->mailer->send($email);
My mailer dsn is:
MAILER_DSN=smtp://[email protected]:[email protected]:587
The mail is received in the inbox of my google workspace account, but the from address is [email protected] not [email protected].
I want to use the from address because of the reputation of my main domain. If the subdomain ‘mail’ gets a bad reputation I can always use a different subdomain.
How can I make google workspace and Symfony use the from address that I specified?