自建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: 'xx@xx.com'  #你的邮箱
mail.password: 'pwd'  #你设置的密码,注意不是邮箱登录密码
mail.use-tls: true #是否使用tls连接
#The email address to send on behalf of
mail.from: 'xx@xx.com' #发送者,填的和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 容器也一样改掉就行。

就会愉快的发现自己可以收到邮件了。

  • 4
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值