Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

CookieMonster's avatar

laravel- configuration amazon ses for mail

I am new to using ses driver on my laravel project. I tried following the guide to implement the ses through here:

https://medium.com/@martin.riedweg/configure-amazon-ses-on-laravel-5-8-in-5-minutes-764c30df6399

I managed to configure everything. This is my .env:


MAIL_DRIVER=ses
MAIL_HOST=email–smtp.ap-south–1.amazonaws.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls

AWS_ACCESS_KEY_ID=xxxxxxxxx
AWS_SECRET_ACCESS_KEY=xxxxxxx
AWS_DEFAULT_REGION=ap-south-1
AWS_BUCKET=

I have created a mailable too like this:

InvoiceAndReceiptEmail.php:


class InvoiceAndReceiptEmail extends Mailable
{
    use Queueable, SerializesModels;

    public $purchase;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct(Purchase $purchase)
    {
        $this->purchase = $purchase;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->subject(' Order Confirmation - ' . $this->purchase->getFormattedNumber())
            ->view('emails.purchases.invoice-receipt-email')
            ->with('purchase', $this->purchase)
            ->attach(public_path(
                '/storage/documents/invoice/' . $this->purchase->purchase_number . '/' . $this->purchase->purchase_number . '.pdf'
            ))
            ->attach(public_path(
                '/storage/documents/invoice/' . $this->purchase->purchase_number . '/' . $this->purchase->purchase_number . '-receipt.pdf'
            ));
    }
}

In my email queue:

class SendInvoiceAndReceiptEmail implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected $emailAddress;
    public $purchase;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($emailAddress, $purchase)
    {
        $this->emailAddress = $emailAddress;
        $this->purchase = $purchase;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $emailInstance = new InvoiceAndReceiptEmail($this->purchase);
        Mail::to($this->emailAddress)->send($emailInstance);
    }
}

While I received the email and it works, but the sender email is from [email protected] and I am expecting it to be from [email protected].

The email should be sent through the ses and the aws access key and secret key should be the identifier to the domain email created.

May I know why is it not working?

Did I overlook something?

0 likes
7 replies
CookieMonster's avatar

Version 5.8.

Right, so I had configured an email using the domain in SES, how do I test it on my development so that when I received an email, it comes from SES (domain email)?

Snapey's avatar

You either fake it with mailtrap or the log driver, or you send it to yourself via SES. I can't think of other options.

You have more config options if you upgrade to Laravel 7.

CookieMonster's avatar

Assuming my configurations are correct, when I deploy the application to AWS server, it should work?

But not in local branch?

Snapey's avatar

Why not both? I can happily send via SES in testing AND production

CookieMonster's avatar

I am not familiar with using mailtrap, I know it's a fake smtp testing environment for emails. But I can't find much tutorial online to setup for AWS in mailtrap.

Snapey's avatar

aws OR mailtrap

create an account https://mailtrap.io

Put your credentials in .env

all mail will be sent to mailtrap instead of real mailboxes. It prevents you accidentally mailing people.

Please or to participate in this conversation.