我正在尝试对使用Symfony 3.4开发的应用程序实施Amazon SES服务,显示错误
class=Swift_RfcComplianceException
message=Address in mailbox given [AKIAQ5NIGV4UVXS6AHUF] does not comply with RFC 2822, 3.6.2.
我以其他方式使用SMTP凭据进行了检查,一切正常。
但是使用swiftmailer在Symfony 3.4上出现上述错误
parameters.yml
email_service_host: email-smtp.us-east-1.amazonaws.com
email_service_port: 25
mailer_encryption: tls
email_service_id: my userID
email_service_password: my password
Config.yml
# Swiftmailer Configuration
swiftmailer:
transport: '%mailer_transport%'
host: '%email_service_host%'
username: '%email_service_id%'
password: '%email_service_password%'
spool: { type: memory }
myContorller.php
$transport = (new Swift_SmtpTransport ($mail_service_host, $mail_service_port))
->setUsername ( $mail_service_id)
->setPassword ( $mail_service_password);
$mailer = new Swift_Mailer ( $transport );
$message = (new Swift_Message('Greetings for Registration'))
->setFrom([$mail_service_id => 'AMS'])
->setTo($flat_owner_email_id)
->setBody (
$this->renderView(
// app/Resources/views/Emails/registration.html.twig
'./flat_owner.html.twig',
array('flatId' => $flat_unique_id,
'associationID'=>$association_unique_id,
'url'=>$url,
'otp'=>$otp_passcode)
),
'text/html'
);
// Send the message to customer
$res = $mailer->send ( $message );
请帮助我解决此问题。