Open
Description
Symfony version(s) affected
6.4
Description
Given the Texter is fakesms
And the DSN is set to fakesms+email://[email protected]&[email protected]
And the SmsMessage
-object has a from
set to "1234567890"
When this SmsMessage
is provided to send()
Then an exception is thrown: Email "1234567890" does not comply with addr-spec of RFC 2822.
How to reproduce
use Symfony\Component\Notifier\Message\SmsMessage;
use Symfony\Component\Notifier\Bridge\FakeSms\FakeSmsEmailTransport;
use Symfony\Component\Mailer\Mailer;
use Symfony\Component\Mailer\Transport\NullTransport;
$texter = new FakeSmsEmailTransport(new Mailer(new NullTransport()), '[email protected]', '[email protected]'); // Normally from DSN
$sms = new SmsMessage(
'+1411111111',
'A new login was detected!',
'+1422222222'
);
$sentMessage = $texter->send($sms);
Possible Solution
@@ -1,6 +1,6 @@
$email = (new Email())
- ->from($message->getFrom() ?: $this->from)
+ ->from($this->from)
->to($this->to)
- ->subject(sprintf('New SMS on phone number: %s', $message->getPhone()))
+ ->subject(sprintf('New SMS on phone number: %s (from: %s)', $message->getPhone(), $message->getFrom()))
->html($message->getSubject())
->text($message->getSubject());