From 4755031e1d5dad4cfe2393287db2acda472f74dd Mon Sep 17 00:00:00 2001 From: Vishnu Narayanan Date: Tue, 29 Nov 2022 09:13:27 +0530 Subject: [PATCH] feat: use sendmail for email as default (#5899) * feat: use sendmail for the email if SMTP_ADDRESS is empty --- .env.example | 5 +++-- config/initializers/mailer.rb | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 62b08a7b1..7f40616b5 100644 --- a/.env.example +++ b/.env.example @@ -60,9 +60,10 @@ MAILER_SENDER_EMAIL=Chatwoot #SMTP domain key is set up for HELO checking SMTP_DOMAIN=chatwoot.com -# the default value is set "mailhog" and is used by docker-compose for development environments, +# Set the value to "mailhog" if using docker-compose for development environments, # Set the value as "localhost" or your SMTP address in other environments -SMTP_ADDRESS=mailhog +# If SMTP_ADDRESS is empty, Chatwoot would try to use sendmail(postfix) +SMTP_ADDRESS= SMTP_PORT=1025 SMTP_USERNAME= SMTP_PASSWORD= diff --git a/config/initializers/mailer.rb b/config/initializers/mailer.rb index bc28e9198..d7359bc0e 100644 --- a/config/initializers/mailer.rb +++ b/config/initializers/mailer.rb @@ -30,6 +30,9 @@ Rails.application.configure do # 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'] + # Use sendmail if using postfix for email + config.action_mailer.delivery_method = :sendmail if ENV['SMTP_ADDRESS'].blank? + ######################################### # Configuration Related to Action MailBox #########################################