Log the following information in email headers: * X-Danbooru-User: the user's name and ID. * X-Danbooru-IP: the user's IP. * X-Danbooru-Session: the users' session ID. * X-Danbooru-URL: the page that triggered the email. * X-Danbooru-Job-Id: the ID of the background job that sent the email. * X-Danbooru-Enqueued-At: when the email was queued as a background job. * X-Danbooru-Dmail: for Dmail notifications, the link to the Dmail. * X-Request-Id: the request ID of the HTTP request that triggered the email. Also make it so we log an event in the APM when we send an email.
Mailers
This directory contains mailers for sending emails. Mailers are kind of like controllers, except for generating emails instead of generating HTML.
The actual email templates live in app/views/user_mailer.
Emails are sent asynchronously using a background job. If sending the email fails, it will be retried later.
Sending emails requires a SMTP server to be configured in config/danbooru_local_config.rb. In production, Amazon SES is used to send emails.
Email templates can be previewed at http://localhost:3000/rails/mailers (assuming you're running bin/rails server on
port 3000, the default).
Example
UserMailer.welcome_user(@user).deliver_later