opengovfoundation / madison

Madison is a platform for lawmakers to share legislation with their citizens, allowing the community to add comments and suggest improvements.
GNU General Public License v3.0
675 stars 108 forks source link

email notifications - sendgrid #1067

Closed IuliiSe closed 7 years ago

IuliiSe commented 7 years ago

I have an issue with the mail service.

The app does not send out email notifications.

I've configured Sendgrid credentials in .env and tested it via telenet (telnet smtp.sendgrid.net 587.

It works. I can send out emails manually.

What should I look into? Can it be the issue with cache? Or database permissions? Or permissions on client/app/js/routes.js?

.env looks like that:

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=database

MAIL_DRIVER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=info@sunrise4am.eu
MAIL_PASSWORD=*******
MAIL_ENCRYPTION=tsl
MAIL_FROM_ADDRESS=notifications@sunrise4am.eu
MAIL_FROM_NAME=Sunrise4am

USERVOICE=null

COOKIE_DOMAIN=.sunrise4am.eu
sethetter commented 7 years ago

@IuliiSe you can check a few things

IuliiSe commented 7 years ago

@sethetter Thanks to pointing me into the right direction!

The jobs were created, but not processed. There were many queued issues in jobs table which look like that:

 | 105 | default | {"job":"mailer@handleQueuedMessage","data":{"view":"email.signup","data":{"token":"iSVT5uNVGuaJJLEf"},"callback":"C:32:\"SuperClosure\\SerializableClosure\":2678:{a:5:{s:4:\"code\";s:216:\"function ($message) use($user) {\n    $message->subject('Welcome to the Madison Community');\n    $message->from('sayhello@opengovfoundation.org', 'Madison');\n    $message->to($user->email);

Is there a need to flush queued items in the table jobs?

Apparently, RemindersController.php UserController.php and Notifier.php did not get the new email settings and used the deafaults.

I also do not see any mailer controller in server/app/Http/Controllers

laravel.log has severa lines on mail:

/server/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(171): Illuminate\Mail\Mailer->addContent(Object(Illuminate\Mail\Message), 'emails.password', NULL, NULL, Array)

/server/vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBroker.php(119): Illuminate\Mail\Mailer->send('emails.password', Array, Object(Closure))

/server/vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBroker.php(93): Illuminate\Auth\Passwords\PasswordBroker->emailResetLink(Object(App\Models\User), '63d22eb7bdee537...', Object(Closure))

Changing email manually in mentioned Controllers does not help.

Do I need to point to the swiftmail directory in .env instead of ? Do I need to chane anything in Mailer.php in /server/vendor/laravel/framework/src/Illuminate/Mail ?

sethetter commented 7 years ago

No you shouldn't need to change anything there. That's Laravel source code, so that should always stay untouched.

Is your .env file under {app_dir}/shared/server/?

Did you check that the laravel-worker service?

IuliiSe commented 7 years ago

@sethetter It works.

Yes, my .env is in shared/server/

But, I failed to find laravel-worker.conf on the server in `etc/

I assumed it was created by one of the cookbooks.

Now, I created a new file laravel-worker.conf and run the supervisor:

server# sudo supervisorctl -c /etc/supervisor/supervisord.conf
laravel-worker:laravel-worker_00 RUNNING    pid 8458, uptime 0:00:13
laravel-worker:laravel-worker_01 RUNNING    pid 8459, uptime 0:00:13
laravel-worker:laravel-worker_02 RUNNING    pid 8460, uptime 0:00:13
laravel-worker:laravel-worker_03 RUNNING    pid 8461, uptime 0:00:13
laravel-worker:laravel-worker_04 RUNNING    pid 8462, uptime 0:00:13
laravel-worker:laravel-worker_05 RUNNING    pid 8463, uptime 0:00:13
laravel-worker:laravel-worker_06 RUNNING    pid 8464, uptime 0:00:13
laravel-worker:laravel-worker_07 RUNNING    pid 8465, uptime 0:00:13

I also needed to change configuration in app.php and mail.php

now it works!

Thank you for the guidance!