Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edited documentation and removed SMTP configs from env #2186

Merged
merged 5 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class Application < Rails::Application
config.site_version = "3.0.0"

# Set application host for mailer
config.action_mailer.default_url_options = { host: ENV['MAILER_HOST'] || "YOUR_APP_HOST" }
KesterTan marked this conversation as resolved.
Show resolved Hide resolved
config.action_mailer.default_url_options = { host: "YOUR_APP_HOST" }

# Configure the host and port of generated urls
config.action_controller.default_url_options = {}
Expand Down
2 changes: 1 addition & 1 deletion config/environments/production.rb.template
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Autolab3::Application.configure do
# config.active_record.auto_explain_threshold_in_seconds = 0.5

# default from
ActionMailer::Base.default :from => ENV.fetch('SMTP_DEFAULT_FROM','[email protected]')
KesterTan marked this conversation as resolved.
Show resolved Hide resolved
ActionMailer::Base.default :from => config_hash['from']

# option for using sendmail
# config.action_mailer.delivery_method = :sendmail
Expand Down
6 changes: 0 additions & 6 deletions config/initializers/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
# confirmation, reset password and unlock tokens in the database.
config.secret_key = ENV['DEVISE_SECRET_KEY']

# ==> Mailer Configuration
# Configure the e-mail address which will be shown in Devise::Mailer,
# note that it will be overwritten if you use your own mailer class
# with default "from" parameter.
config.mailer_sender = ENV['SMTP_DEFAULT_FROM']

# Configure the class responsible to send e-mails.
# config.mailer = 'Devise::Mailer'

Expand Down
31 changes: 18 additions & 13 deletions docs/installation/mailing.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@

Autolab requires mailing to allow users to register accounts and reset passwords. You will also be able to make announcements through Autolab as well. The recommended approach is to setup Autolab to use a SMTP server, such as [mailgun](https://mailgun.com), [SendGrid](https://sendgrid.com), [Amazon SES](https://aws.amazon.com/ses/) or any other valid SMTP mail servers to send out email.

We intend this instructions mainly for production usage.
KesterTan marked this conversation as resolved.
Show resolved Hide resolved
We intend this instructions mainly for production usage.
KesterTan marked this conversation as resolved.
Show resolved Hide resolved

## Mailing for Autolab Docker Installation
To set Autolab Docker up for a custom SMTP Server, update the following in `.env` that was created for you.
To set up Autolab for a custom SMTP Server, configure settings by clicking `Manage Autolab` > `Configure Autolab` > `SMTP Config`.

## I don't have a domain name, will mailing work?
Mailing has been tested to work with SendGrid without a domain name (using the IP of the server as the domain name for the purposes of the configuration above), although the absence of a domain name will likely result in the email to be flagged as spam. For the purpose of testing, a testing mailbox service like [MailTrap](https://mailtrap.io/) is recommended.

## What if I'm running an outdated version of Autolab?
If you are running an Autolab version less than v3.0.0, refer to the documentation down below to configure SMTP.

### Mailing for Autolab Docker Installation
To set Autolab Docker up for a custom SMTP Server, update the following in `.env` that was created for you.

1. Update the host domain

Expand Down Expand Up @@ -35,7 +43,7 @@ To set Autolab Docker up for a custom SMTP Server, update the following in `.env

After which, doing a `docker-compose down` followed by `docker-compose up -d` will allow you to see the changes.

## Mailing for Autolab Manual Installation
### Mailing for Autolab Manual Installation
To set Autolab up to use a custom SMTP Server, you will need to make edits to the `.env` and `production.rb` files that you have created. (If you would like to test it in development, add the following settings into `development.rb`). Both `production.rb` and `development.rb` are located under `config/environments`

1. Update the host domain of your Autolab instance in `.env`
Expand All @@ -46,7 +54,7 @@ To set Autolab up to use a custom SMTP Server, you will need to make edits to th
The value should be the domain in which Autolab is hosted on. (e.g. `autolab.andrew.cmu.edu`)

2. Update the custom smtp server settings in `production.rb`

:::ruby
config.action_mailer.smtp_settings = {
address: 'smtp.example.com',
Expand All @@ -57,17 +65,14 @@ To set Autolab up to use a custom SMTP Server, you will need to make edits to th
password: 'example',
domain: 'example.com',
}
Refer to the SMTP settings instructions that your selected service provides you such as [SendGrid SMTP for Ruby on Rails](https://sendgrid.com/docs/for-developers/sending-email/rubyonrails/), [Amazon SES](https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-smtp.html).

Refer to the SMTP settings instructions that your selected service provides you such as [SendGrid SMTP for Ruby on Rails](https://sendgrid.com/docs/for-developers/sending-email/rubyonrails/), [Amazon SES](https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-smtp.html).

3. Update the "from" setting in `production.rb`

:::ruby
ActionMailer::Base.default :from => '[email protected]'

Here the from address **must** be a address that your SMTP service permits you to send from. Oftentimes it is the same as your user_name in the smtp settings.

Make sure to restart your Autolab client to see the changes.
Here the from address **must** be a address that your SMTP service permits you to send from. Oftentimes it is the same as your user_name in the smtp settings.
KesterTan marked this conversation as resolved.
Show resolved Hide resolved

# I don't have a domain name, will mailing work?
Mailing has been tested to work with SendGrid without a domain name (using the IP of the server as the domain name for the purposes of the configuration above), although the absence of a domain name will likely result in the email to be flagged as spam. For the purpose of testing, a testing mailbox service like [MailTrap](https://mailtrap.io/) is recommended.
Make sure to restart your Autolab client to see the changes.