今天gitlab 的email提醒突然不工作了。需要增加配置,奇怪为什么之前那么神奇什么都不要配?
在config/gitlab.yml中设置:
## Email settings
# Email address used in the "From" field in mails sent by GitLab
#email_from: shu_chen@esri.com
from: your_account@your_mail.com
host: your_gitlab_server_host_name
在config/environment/production.rb文件中end前添加
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => 'your_smtp_server',
:port => 25,
:domain => 'your_gitlab_server_domain',
:authentication => :plain,
:user_name => 'your_account',
:password => 'your_password',
:enable_starttls_auto => true
}
还要安装sendmail
apt-get install sendmail
还是收不到email,检查一下日志,什么也没有。查看系统日志/var/log/syslog, 看到sendmail错误信息:
Feb 19 12:47:19 gitlab sendmail[42520]: My unqualified host name (gitlab) unknown; sleeping for retry
Feb 19 12:48:19 gitlab sendmail[42520]: unable to qualify my own domain name (gitlab) -- using short name
Feb 19 12:48:19 gitlab sendmail[42520]: gethostbyaddr(10.112.18.182) failed: 2
原来是/etc/hosts配置的顺序问题:
127.0.0.1 localhost.localdomain localhost gitlab
记住,写成一行,并且localhost要放在机器名前面。
现在OK。