Skip to content

Commit

Permalink
Merge branch 'joanna-visual-cues-improvements' of github.com:autolab/…
Browse files Browse the repository at this point in the history
…Autolab into joanna-visual-cues-improvements
  • Loading branch information
jlge committed Sep 15, 2024
2 parents 42da4da + 8e8744f commit f91f7a6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
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" }
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
6 changes: 3 additions & 3 deletions config/environments/production.rb.template
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ Autolab3::Application.configure do
# with SQLite, MySQL, and PostgreSQL)
# config.active_record.auto_explain_threshold_in_seconds = 0.5

# default from
ActionMailer::Base.default :from => ENV.fetch('SMTP_DEFAULT_FROM','[email protected]')

# option for using sendmail
# config.action_mailer.delivery_method = :sendmail

Expand Down Expand Up @@ -112,6 +109,9 @@ Autolab3::Application.configure do
if File.size?("#{Rails.configuration.config_location}/smtp_config.yml")
config_hash = YAML.safe_load(File.read("#{Rails.configuration.config_location}/smtp_config.yml"))

# default from
ActionMailer::Base.default :from => config_hash['from']

config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
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
34 changes: 20 additions & 14 deletions docs/installation/mailing.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@

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.
We intend these instructions mainly for production usage.

## 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.
## Mailing for Autolab version >=3.0.0
To set up Autolab (>=3.0.0) 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 All @@ -31,11 +40,11 @@ To set Autolab Docker up for a custom SMTP Server, update the following in `.env
:::
[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.
Here the from address **must** be an address that your SMTP service permits you to send from. Oftentimes it is the same as your user_name in the smtp settings.

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 +55,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 +66,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 an address that your SMTP service permits you to send from. Oftentimes it is the same as your user_name in the smtp settings.

# 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.

0 comments on commit f91f7a6

Please sign in to comment.