I tried to send email using AWS SES SMTP and this is how I did.
.env
MAIL_MAILER=smtp
MAIL_HOST=email-smtp.{AWS_REGION}.amazonaws.com
MAIL_PORT=587
MAIL_USERNAME="${AWS_SES_USER_NAME}"
MAIL_PASSWORD="${AWS_SES_USER_PASS}"
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"
Code to send email
Mail::raw('This is email test', function ($email_message) {
$email_message->from('[email protected]', 'Oleg Postoev');
$email_message->to('[email protected]');
$email_message->subject('Email Test');
$email_message->setBody('This is email test', 'text/html');
});
After run above code, I got this error
TypeError: SymfonyComponentMimeMessage::setBody(): Argument #1 ($body) must be of type ?SymfonyComponentMimePartAbstractPart, string given, called in E:PetChecklaravel-apivendorlaravelframeworksrcIlluminateSupportTraitsForwardsCalls.php on line 23 in file E:PetChecklaravel-apivendorsymfonymimeMessage.php on line 45
I am using Laravel 10 and AWS SES Sandbox account.
Can anyone help me to fix this problem?