自建sentry服務器後,無法收到郵件問題(已解決

按着這篇文章搭建了sentry,也能正常啓動訪問,但是卻始終收不到郵件,弄了很久才弄明白。

首先說明裏面的坑,才能理解爲什麼要這麼配置。
sentry環境用的是python2.7,發郵件使用的是django的email,使用的版本是django 1.6,而django1.7才支持使用ssl。
也就是說,sentry配置默認不支持ssl郵件發送。
而由於25端口(非ssl)默認被阿里雲封禁,所以阿里雲的服務器也不能使用25端口發送。

github裏有該問題的詳細討論,鏈接
 

話不多說,開始

 

首先sentry服務是正常啓動的,類似這樣

docker ps -a

sentry-worker是sentry的異步隊列

sentry-corn 是sentry的定時任務

my-sentry是主程序

sentry-postgres 是數據庫

sentry-redis是緩存

由於測試郵件是使用sentry的主程序測試的,而平常收到的異常日誌和邀請郵件是sentry-worker 異步執行的,

如果只改了主程序,那麼就會出現測試郵件的時候正常,卻收不到異常日誌和邀請郵件的情況。

配置:

第一步:進入主程序的docker 容器內,“9af0a040d388 “是容器id。

docker exec -it 9af0a040d388  /bin/bash 

第二步:安裝vim程序,這樣才能在容器內編輯配置文件

apt-get update
apt-get vim

第三步:進入目錄,修改配置文件

cd /etc/sentry/
vim config.yml 

第四步:配置郵箱

# While a lot of configuration in Sentry can be changed via the UI, for all
# new-style config (as of 8.0) you can also declare values here in this file
# to enforce defaults or to ensure they cannot be changed via the UI. For more
# information see the Sentry documentation.

###############
# Mail Server #
###############

# 修改這裏,取消原本的註釋
mail.backend: 'django_smtp_ssl.SSLEmailBackend'  # 使用django的ssl插件,解決django1.6不能使用ssl的問題
mail.host: 'smtp.exmail.qq.com' #郵箱對應的smtp域名
mail.port: 465 #郵箱對應端口
mail.username: '[email protected]'  #你的郵箱
mail.password: 'pwd'  #你設置的密碼,注意不是郵箱登錄密碼
mail.use-tls: true #是否使用tls連接
#The email address to send on behalf of
mail.from: '[email protected]' #發送者,填的和user一樣就行
mail.list-namespace :'xx.com' #不清楚用途,需要填郵箱的域名名稱,和user域名一致

# If you'd like to configure email replies, enable this.
# mail.enable-replies: false

# When email-replies are enabled, this value is used in the Reply-To header
# mail.reply-hostname: ''


第五步:安裝django的插件

pip install django-smtp-ssl

第六步:退出容器,再重啓容器

exit
docker restart 9af0a040d388

然後將sentry-worker 容器也一樣改掉就行。

就會愉快的發現自己可以收到郵件了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章