Search code examples
laravelamazon-web-servicessmtpamazon-iamamazon-ses

(AWS SES / Laravel) - Connection could not be established with host smtp.mailtrap.io


I've been trying to setup mailing in Laravel 7 with AWS SES and have setup all my credentials properly and set my drivers to SES.

I get the following error when attempting to send an email verification with the default built in functionality.

Connection could not be established with host smtp.mailtrap.io :stream_socket_client(): unable to connect to tcp://smtp.mailtrap.io:2465 (Operation timed out)

.env

MAIL_DRIVER=ses
MAIL_FROM_ADDRESS=no-reply@taxsion.com
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=HIDDEN
AWS_SECRET_ACCESS_KEY=HIDDEN
AWS_DEFAULT_REGION=us-east-1

I have ensured that the AWS key and secret have full access to SES, in my config/services.php I am setting it to use these credentials.

'ses' => [
    'key' => env('AWS_ACCESS_KEY_ID'),
    'secret' => env('AWS_SECRET_ACCESS_KEY'),
    'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
]

I have searched through numerous "solutions" and have tried creating a separate user for SES only with no luck.

Any help would be great, thanks!


Solution

  • The issue was that my .env was not being loaded due to caching.

    Simply running php artisan config:clear cleared the cached config and updated it with my new parameters.

    My .env contains the following:

    MAIL_MAILER=ses
    MAIL_FROM_ADDRESS=no-reply@domain.com
    MAIL_FROM_NAME="${APP_NAME}"