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

Allow SMTP Port in Email Settings to be set to an environment variable #3740

Closed
rungta opened this issue Jan 29, 2019 · 7 comments
Closed

Allow SMTP Port in Email Settings to be set to an environment variable #3740

rungta opened this issue Jan 29, 2019 · 7 comments

Comments

@rungta
Copy link

rungta commented Jan 29, 2019

Description

With 3.1 we can now use environment variables for SMTP email settings. But this feature was not extended to the SMTP Port field. Different SMTP configurations on dev and production cannot truly live in the .env file if both SMTP servers do not share the same port (e.g. Mailgun on production uses 587, but Mailtrap on dev uses 465).

Steps to reproduce

  1. Go to Settings > Email
  2. Set Transport Type to SMTP
  3. Set the value of the Port field to a variable from your .env file, like $SMTP_PORT

Additional info

  • Craft version: 3.1.5
@brandonkelly
Copy link
Member

Correct. Is that something you need to set for each environment? Seems like 99% of the time the standard ports are used.

@rungta rungta changed the title All SMTP Port in Email Settings to be set to an environment variable Allow SMTP Port in Email Settings to be set to an environment variable Jan 30, 2019
@rungta
Copy link
Author

rungta commented Jan 30, 2019

We use Mailtrap (25, 465, 2525) for our dev environment installs and Mailgun (25, 587, 465) or Amazon SES (25, 587, 2587) for staging and production installs, and since these services don’t always share the same port, we need to set separate port values on dev and production.

(25 is common but often blocked.)

@rungta
Copy link
Author

rungta commented Jan 30, 2019

Sendgrid and Mandrill both offer the same set: 25, 587, 2525

@echantigny
Copy link
Contributor

echantigny commented Jan 30, 2019

I'm also looking into this. Locally, I use my gmail to test, but on the production server, it has it's own SMTP server that I can't use locally (blocked to localhost). I would like to be able to set the transport type somehow, and the port would be required too at this point.

EDIT: I have to add that I'm using the project.yaml file so this also gets saved there, which overwrites the transport type on my prod server.

@brandonkelly
Copy link
Member

Alright, as of the next release it will be possible to set Port to an environment variable.

@echantigny
Copy link
Contributor

Any chance that will include a way to set the transport type too? I would love to use the project config file, but impossible for me without a way to save that in a config.

@brandonkelly
Copy link
Member

No that wouldn’t be possible; that’s why we allow you to override the mailer transport at runtime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants