mastodon / mastodon

Your self-hosted, globally interconnected microblogging community
https://joinmastodon.org
GNU Affero General Public License v3.0
46.96k stars 6.95k forks source link

Sending emails is not working with docker and after adjusting variables #18579

Open timaschew opened 2 years ago

timaschew commented 2 years ago

Steps to reproduce the problem

  1. Clone repo and checkout v3.5.2
  2. Go through docker-compose run --rm web bundle exec rake mastodon:setup, email test is working (I receive an email)
  3. run docker-compose up -d
  4. Register a new user account and no email confirmation is send
  5. Manually adjusted SMTP variables in .env.production
  6. run docker-compose restart
  7. Try to reset password via email

If I change variables in .env.production file, is it enough to just do a ´docker-compose restart`?

Expected behaviour

Email is send

Actual behaviour

No email is send; error in the logs

Specifications

sidekiq_1    | [ActiveJob] [ActionMailer::MailDeliveryJob] [418ad793-485b-42cf-9d04-a6832adc384f] Error performing ActionMailer::MailDeliveryJob (Job ID: 418ad793-485b-42cf-9d04-a6832adc384f) from Sidekiq(default) in 385.04ms: Net::SMTPFatalError (554 5.7.1 <xxx@yyy.de>: Relay access denied

sidekiq_1    | 2022-05-31T09:03:20.864Z pid=6 tid=2dcq WARN: {"context":"Job raised exception","job":{"retry":true,"queue":"default","class":"ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper","wrapped":"ActionMailer::MailDeliveryJob","args":[{"job_class":"ActionMailer::MailDeliveryJob","job_id":"418ad793-485b-42cf-9d04-a6832adc384f","provider_job_id":null,"queue_name":"default","priority":null,"arguments":["UserMailer","reset_password_instructions","deliver_now",{"args":[{"_aj_globalid":"gid://mastodon/User/2"},"hcg2TN-SnAK4Dxcz_uU5"],"_aj_ruby2_keywords":["args"]}],"executions":0,"exception_executions":{},"locale":"de","timezone":"UTC","enqueued_at":"2022-05-31T09:02:57Z"}],"jid":"c3ec24542dfd42cf0624d4e6","created_at":1653987777.041209,"enqueued_at":1653987800.4855535,"error_message":"554 5.7.1 <xxx@yyy.de>: Relay access denied\n","error_class":"Net::SMTPFatalError","failed_at":1653987777.4326482,"retry_count":0},"jobstr":"{\"retry\":true,\"queue\":\"default\",\"class\":\"ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper\",\"wrapped\":\"ActionMailer::MailDeliveryJob\",\"args\":[{\"job_class\":\"ActionMailer::MailDeliveryJob\",\"job_id\":\"418ad793-485b-42cf-9d04-a6832adc384f\",\"provider_job_id\":null,\"queue_name\":\"default\",\"priority\":null,\"arguments\":[\"UserMailer\",\"reset_password_instructions\",\"deliver_now\",{\"args\":[{\"_aj_globalid\":\"gid://mastodon/User/2\"},\"hcg2TN-SnAK4Dxcz_uU5\"],\"_aj_ruby2_keywords\":[\"args\"]}],\"executions\":0,\"exception_executions\":{},\"locale\":\"de\",\"timezone\":\"UTC\",\"enqueued_at\":\"2022-05-31T09:02:57Z\"}],\"jid\":\"c3ec24542dfd42cf0624d4e6\",\"created_at\":1653987777.041209,\"enqueued_at\":1653987800.4855535,\"error_message\":\"554 5.7.1 <xxx@yyy.de>: Relay access denied\\n\",\"error_class\":\"Net::SMTPFatalError\",\"failed_at\":1653987777.4326482,\"retry_count\":0}"}

sidekiq_1    | 2022-05-31T09:03:20.864Z pid=6 tid=2dcq WARN: Net::SMTPFatalError: 554 5.7.1 <xxx@yyy.de>: Relay access denied

Here is my config:

SMTP_SERVER=xxx.yyy.com
SMTP_PORT=587
SMTP_AUTH_METHOD=plain
SMTP_SSL=true
SMTP_OPENSSL_VERIFY_MODE=none
SMTP_FROM_ADDRESS=xxx@yyy.net
SMTP_PASSWORD=xxx
SMTP_LOGIN=yyy
SMTP_DELIVERY_METHOD=smtp

It's realy confusing that the samle env file has totally different variables: https://github.com/mastodon/mastodon/blob/main/.env.production.sample

Also the the mastodon:setup is not setting the server, login, password, see https://github.com/mastodon/mastodon/issues/18384

For my final config I was picking variables from here: https://github.com/mastodon/mastodon/discussions/17923

ClearlyClaire commented 2 years ago

If the email test is working, and you've copied the contents of the .env.production file as output by the mastodon:setup task, sending e-mails should work… it seems the most likely explanations are that either you did not copy them correctly, or they weren't read correctly. Does your password contain characters such as a space, ", ', # or $ or {?

It's realy confusing that the samle env file has totally different variables: https://github.com/mastodon/mastodon/blob/main/.env.production.sample

I'm not sure what you mean. The .env.production.sample features a small subset of the available configuration variables.

For my final config I was picking variables from here: #17923

If the test from mastodon:setup worked, you should be using its output as your .env.production.

If I change variables in .env.production file, is it enough to just do a ´docker-compose restart`?

As far as I know, yes.

timaschew commented 2 years ago

aI will try to setup it from scratch, but please tell me how to do a setup with docker. I did not found any instructions.

When I try to do docker-compose run -e "RAILS_ENV=RAILS_ENV" --rm web bundle exec rake mastodon:setup after a fresh git clone, I receive this error:

ERROR: Couldn't find env file: /root/mastodon/.env.production`

ClearlyClaire commented 2 years ago

Copy the .env.production.sample file or create an empty file. The file will then have to be (manually) overwritten by the output shown by mastodon:setup.