self-hosted icon indicating copy to clipboard operation
self-hosted copied to clipboard

Unable to send email after configuring aws ses as smtp host

Open sdarshil opened this issue 4 years ago • 18 comments

Version

21.7.0

Steps to Reproduce

i have done my sentry setup as described i have used this in my config.yml :

mail.backend: ‘smtp’ mail.host: ‘email-smtp.us-east-1.amazonaws.com’ mail.port: 587 mail.username: 'AKIAUEXXXXXXX ’ mail.password: 'BFW2TafXXXXX ’ mail.use-tls: True mail.from: ‘darsXXXXXX’

but i am unable to send test mail , it says check server logs in server logs i am unable to find any logs regarding email queue !

nginx logs :
2022/02/08 06:30:45 [error] 23#23: *1 upstream prematurely closed connection while reading response header from upstream, client: 43.251.223.179, server: , request: "POST /api/0/internal/mail/ HTTP/1.1", upstream: "http://192.168.144.25:9000/api/0/internal/mail/", host: "45.79.216.101:9000", referrer: "http://45.79.216.101:9000/manage/status/mail/"

Expected Result

Test Email Sent

Actual Result

Check server logs , email not sent !

sdarshil avatar Feb 08 '22 06:02 sdarshil

Have you modified SENTRY_MAIL_HOST in .env ?

misschak avatar Feb 08 '22 09:02 misschak

What @misschak said. 😁

chadwhitacre avatar Feb 08 '22 15:02 chadwhitacre

@misschak no i have not added but now i have added that in .env file , and i got diffrent error this time .

it says connection refused ! image

sdarshil avatar Feb 09 '22 04:02 sdarshil

@sdarshil Make sure you have followed https://develop.sentry.dev/self-hosted/email/ completely.

Have you restarted your sentry instance after adding using docker-compose up -d?

P.S. It's worth taking a look at https://github.com/getsentry/self-hosted#customize-dotenv-env-file instead of changing .env itself.

aminvakil avatar Feb 09 '22 13:02 aminvakil

I HAVE USED THIS CONFIG AND ADDED HOST IN .env file too ,

// mail.backend: 'smtp' # Use dummy if you want to disable email entirely mail.host: 'email-smtp.us-east-1.amazonaws.com' mail.port: 587 mail.username: 'AKIAUE3JIZBXXXXXXXXXX' mail.password: 'BBer9qyYW2txgHPVSqEPSAVXXXXXXXXXXXX' mail.use-tls: True mail.from: '[email protected]'

sdarshil avatar Feb 10 '22 18:02 sdarshil

@aminvakil image THIS NETWORK CALL FAILED!

sdarshil avatar Feb 11 '22 05:02 sdarshil

What do the logs in the web container show for the 500?

chadwhitacre avatar Feb 11 '22 13:02 chadwhitacre

@aminvakil image THIS NETWORK CALL FAILED!

Also I see you have stated you're using 21.7.0 at first, but I see 22.2.0.dev0 in this image, how have you upgraded? There may be a issue there.

aminvakil avatar Feb 11 '22 21:02 aminvakil

hi @aminvakil actually i was using that version but now i have delete all the volumes with containers and now i am using the latest one

sdarshil avatar Feb 12 '22 15:02 sdarshil

@chadwhitacre image

sdarshil avatar Feb 12 '22 15:02 sdarshil

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

github-actions[bot] avatar Mar 05 '22 18:03 github-actions[bot]

Did you ever have any luck with this @sdarshil? Sorry I was unable to see anything useful in the screenshot you posted, too much noise. :(

chadwhitacre avatar Mar 07 '22 23:03 chadwhitacre

@chadwhitacre no i still didnt have luck with this issue ! \

sdarshil avatar Mar 19 '22 05:03 sdarshil

Also seeing this issue on a fresh install (Sentry 22.3.0 - 08d452b)

Tried SES as well as a self-hosted mail server, but Sentry always reports:

{"error":"[Errno 111] Connection refused"}

Have confirmed it's not a network issue, as telnet from the same EC2 instance to any of the mail servers I tried does work. In the case of the self-hosted mail server, the logs show Sentry does not even try to connect.

I don't know what is blocking Sentry, but it seems to be somewhere inside docker.

I have my .env and sentry/config.yml set correctly (as per comments and documentation mentioned above) and have tried both re-running install.sh and docker-composer up -d each time I try different settings.

#mail.backend: 'smtp'  # Use dummy if you want to disable email entirely
mail.host: 'email-smtp.eu-west-1.amazonaws.com'
mail.port: 587
mail.username: '...'
mail.password: '...'
mail.use-tls: true
mail.use-ssl: false

I don't know where to dig deeper for better logs.

The web container just shows it's forwarding the server error:

15:07:24 [INFO] sentry.access.api: api.access (method='POST' view='sentry.api.endpoints.internal.mail.InternalMailEndpoint' response=500 user_id='1' is_app='None' token_type='None' is_frontend_request='True' organization_id='None' auth_id='None' path='/api/0/internal/mail/' caller_ip='172.20.0.1' user_agent='Mozilla/5.0 Firefox/98.0' rate_limited='False' rate_limit_category='user' request_duration_seconds=0.029939889907836914 rate_limit_type='RateLimitType.NOT_LIMITED' concurrent_limit='300' concurrent_requests='1')
15:07:24 [ERROR] django.request: Internal Server Error: /api/0/internal/mail/ (status_code=500 request=<WSGIRequest: POST '/api/0/internal/mail/'>)

Can any of the other containers provide some logs that might help?

bnxdev avatar Mar 24 '22 15:03 bnxdev

Same issue like mine waiting for response

sdarshil avatar Mar 25 '22 07:03 sdarshil

I feel stupid - but figured it out. A misunderstanding of the config options was the issue for me.

I edited the .env and set SENTRY_MAIL_HOST=email-smtp.eu-west-1.amazonaws.com because I want "to be able to send emails"!

This actually just sets the hostname of the exim/smtp container to that, so it comes as no surprise when you also add in the mail config to config.yml it tries connecting to the exim/smtp container and that won't work.

[...]$ sudo docker exec df7057344742 hostname
email-smtp.eu-west-1.amazonaws.com

Editing the .env and reinstalling does the trick.

[...]$ sudo docker exec ce656c2d29fc hostname
ce656c2d29fc

Now my mail works 😄

bnxdev avatar Mar 31 '22 13:03 bnxdev

Thanks for posting back @bnxdev, glad you figured it out!

Is there something we could change in the docs to make this clearer?

Also @sdarshil does this help you out?

chadwhitacre avatar Mar 31 '22 14:03 chadwhitacre

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

github-actions[bot] avatar Apr 22 '22 00:04 github-actions[bot]