2

I am using the code below to queue emails using Amazon SQS, the message do queue up in the Amazon SQS queue but I don't know how to process it so that the emails are delivered to their recipient. I am using a shared server for my project where I have no access to SSH.

//User Registration Email
static function UserRegEmail($LastName,$FirstName,$Email){

    $user = array('LastName' => $LastName,
                'FirstName' => $FirstName,
                'Email' => $Email);

     $data = array(
        'LastName' => $LastName, 
        'FirstName'=> $FirstName,
        'senderName' => 'MyCompanyName', 
        'Email' => $Email
    );

        Mail::queue('emails.user_welcome', $data, function($message) use ($user)
        {
            $message->from( '[email protected]', 'MyCompanyName' );
            $message->to($user['Email'], $user['LastName'].' '.$user['FirstName'])->subject('Welcome!');
        });

}

1 Answer 1

1

You have to configure queues first to be able to use Mail::queue. There's a chapter in the docs that explains it pretty well.
I've no experience with Amazon SQS, but Laravel theoretically supports it.

Head over to /app/config/queue.php and change the config

'default' => 'sqs'

And fill in your details for connections > sqs

After that, everything should just work :)

Sign up to request clarification or add additional context in comments.

7 Comments

The configuration has being done, and jobs are queuing successfully. I just want to know how to fire the jobs..
Ups I'm sorry, should have read slower... Are you able to set up cronjobs?
I know how to, is it needed?
I don't know if it really is needed, but to "run" the queue there's the artisan command queue:work. So you could have a cronjob that runs php artisan queue:work every 5 minutes or so
Don't have access to SSH cause I am on a shared sever, can't do php artisan queue:work
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.