Presentation is loading. Please wait.

Presentation is loading. Please wait.

Sending s with SendGrid and Laravel

Similar presentations


Presentation on theme: "Sending s with SendGrid and Laravel"— Presentation transcript:

1 Sending Emails with SendGrid and Laravel
Sayed Ahmed Computer Engineering, BUET, Bangladesh (2001) MSc. Computer Science, U of Manitoba, Canada Exploring Computing from 1996

2 Requirements A SendGrid Account Beanstalkd Laravel go mail worker
Cloud based delivery services Beanstalkd queue Laravel go mail worker Laravel Mail sender using Sendgrid [as an example] worker/blob/master/laravel-go-mail- worker/app/commands/Queue Command.php worker/blob/master/go/src/zackkitzmiller/laravel-go-mail-worker/main.go

3 Must Watch Mail Queue configuration for Laravel
app/config/queue.php Basic Mail Configuration for Laravel [Not a Must] app/config/mail.php

4 How These All Will Work You need to queue the message in Beanstalkd
You need to configure Laravel and Laravel Go Mailer for that From your code, you need to use methods to queue the message $message = "This is a queue test job. We won't really need to pass data for this demo."; Queue::push('QueueDemo', array('message' => $message)); This apparently looks like will also work Mail::queueOn('queue-name', ' s.welcome', $data, function($message) { $message 'John Smith') ->subject('Welcome!'); }); Then the GO application will send this It’s Laravel go mail worker Then Go mailer will use SendGrid to send the mail

5 How These All Will Work Configuration for Go mail worker
BEANSTALKD: location of the beanstalk installation (e.g. localhost:11300) SENDGRID_USER: username for sendgrid account SENDGRID_PASS: password for sendgrid account

6 Installation Install Go Mailer
Artisan command send. Will do that for you Not sure yet that it will work; after working with it, I will update Though you can get the copy of the Laravel- go-mailer and use that for sure

7 Miscellaneous How to Download and Install Beanstalkd
Src: git clone git://github.com/kr/beanstalkd.git Install: Mac: sudo port install beanstalkd Debian: sudo apt-get install beanstalkd Ubuntu: sudo apt-get install beanstalkd Fedora: su -c 'yum install beanstalkd' Sending s from Laravel using Mail Servers such as SwiftMailer Mail Queue tutorial for Laravel

8 Miscellaneous Beanstalkd listed as the default in Laravel- go-mailer queue config file mail-worker/blob/master/laravel-go-mail- worker/app/config/queue.php These are the environment variables Set SENDGRID_USER, SENDGRID_PASS, and BEANSTALKD env vars Can be set in Linux profile type files Also from within PHP you can set

9 Environment Variables and PHP
echo 'My username is ' .$_ENV["USER"] . '!'; // Example use of getenv() $ip = getenv('REMOTE_ADDR'); putenv("UNIQID=$uniqid");

10 Beanstalkd Configuration File Content
You can know but you will not need to work with it much for basic functionality [program:qlistener] command=php /var/www/laravel/artisan queue:listen process_name=%(program_name)s numprocs=1 numprocs_start=0 autostart=true autorestart=true startsecs=1 startretries=3 exitcodes=0,2 stopsignal=TERM stopwaitsecs=10

11 Beanstalkd Configuration File Content
user=ubuntu redirect_stderr=false stdout_logfile=/var/log/supervisor/qlistener-stdout.log stdout_logfile_maxbytes=50MB stdout_logfile_backups=10 stdout_capture_maxbytes=0 stdout_events_enabled=false stderr_logfile=/var/log/supervisor/qlistener-stderr.log stderr_logfile_maxbytes=50MB stderr_logfile_backups=10 stderr_capture_maxbytes=0 tderr_events_enabled=false environment=LARAVEL_ENV="production" serverurl=AUTO

12 Reference laravel-sendgrid-beanstalkd-and-go


Download ppt "Sending s with SendGrid and Laravel"

Similar presentations


Ads by Google