I want to skip rfc 2822 complain of laravel anyhow. I know it is not a good practice but I need to do it anyhow. I can see exception is throwing from vendor/symfony/mime/Address.php in vendor.
But how can I skip this without changing the vendor file. When the laravel was using swiftmailer, We can override creating a custom class and binding from service provider something like below.
But I am struglling how to do the same thing with Symphony Mailer in Laravel 10.
class AllowNonRfcComplaintEmailValidator extends EmailValidator
{
/**
* 最低限、@が含まれていて、ドメインとアカウント名が含まれているメールアドレスは許可します
* @param string $email
* @param EmailValidation $emailValidation
* @return bool
*/
public function isValid($email, EmailValidation $emailValidation): bool
{
// warningsとerrorのプロパティを埋める
parent::isValid($email, $emailValidation);
if (substr_count($email, '@') !== 1) {
return false;
}
list($account, $domain) = explode('@', $email);
if (strlen($account) > 0 && strlen($domain) > 0) {
return true;
}
return false;
}
}
Swift::init(function () {
Swift_DependencyContainer::getInstance()
->register('email.validator')
->asSharedInstanceOf(AllowNonRfcComplaintEmailValidator::class);
}
);
How can I do this in laravel 10 with Symphony mailer.
Thank you in advance,