feat(email): Integrate LeadMail API for transactional emails
Some checks failed
Lock Threads / action (push) Has been cancelled
Some checks failed
Lock Threads / action (push) Has been cancelled
Replace SMTP with LeadMail API service for sending system transactional emails (password resets, invitations, notifications). LeadMail provides built-in email verification via Verifalia and async queue-based sending. Configuration: - Set LEADMAIL_API_TOKEN and LEADMAIL_API_URL in .env - Falls back to SMTP if LeadMail token not present - Works via custom ActionMailer delivery method (stable across upstream merges) Includes: - LeadmailDelivery class with full spec coverage - Support for multipart messages, attachments, CC/BCC - Error handling and logging with message tracking - Documentation in docs/LEADMAIL_INTEGRATION.md
This commit is contained in:
@@ -27,11 +27,21 @@ Rails.application.configure do
|
||||
smtp_settings[:open_timeout] = ENV['SMTP_OPEN_TIMEOUT'].to_i if ENV['SMTP_OPEN_TIMEOUT'].present?
|
||||
smtp_settings[:read_timeout] = ENV['SMTP_READ_TIMEOUT'].to_i if ENV['SMTP_READ_TIMEOUT'].present?
|
||||
|
||||
config.action_mailer.delivery_method = :smtp unless Rails.env.test?
|
||||
config.action_mailer.smtp_settings = smtp_settings
|
||||
# Use LeadMail API if configured
|
||||
if ENV['LEADMAIL_API_TOKEN'].present?
|
||||
ActionMailer::Base.add_delivery_method :leadmail, LeadmailDelivery
|
||||
config.action_mailer.delivery_method = :leadmail
|
||||
config.action_mailer.leadmail_settings = {
|
||||
api_url: ENV.fetch('LEADMAIL_API_URL', 'https://mail.leadmagnet.dev/api/v1'),
|
||||
token: ENV['LEADMAIL_API_TOKEN']
|
||||
}
|
||||
elsif !Rails.env.test?
|
||||
config.action_mailer.delivery_method = :smtp
|
||||
config.action_mailer.smtp_settings = smtp_settings
|
||||
|
||||
# Use sendmail if using postfix for email
|
||||
config.action_mailer.delivery_method = :sendmail if ENV['SMTP_ADDRESS'].blank?
|
||||
# Use sendmail if using postfix for email
|
||||
config.action_mailer.delivery_method = :sendmail if ENV['SMTP_ADDRESS'].blank?
|
||||
end
|
||||
|
||||
# You can use letter opener for your local development by setting the environment variable
|
||||
config.action_mailer.delivery_method = :letter_opener if Rails.env.development? && ENV['LETTER_OPENER']
|
||||
|
||||
Reference in New Issue
Block a user