Rundeck Gmail SMTP设置

时间:2019-01-03 23:19:31

标签: ssl smtp gmail rundeck mailx

我已经尝试了数周时间来配置rundeck以使用Centos7虚拟机上的gmail smtp设置发送电子邮件。我确实为服务器配置了ssl证书(已购买)。不确定是否与此有关。到目前为止,我有:

  • 已将“ /etc/rundeck/rundeck-config.properties”文件转换为 “ /etc/rundeck/rundeck-config.groovy”文件
  • 使用以下设置更新“ / etc / sysconfig / rundeckd”文件。 “导出RUNDECK_WITH_SSL = true 导出RDECK_CONFIG_FILE =“ / etc / rundeck / rundeck-config.groovy”
  • 用以下文本编辑了我的“ /etc/rundeck/rundeck-config.groovy”。

loglevel.default="INFO"
rdeck.base="/var/lib/rundeck"
rss.enabled=false

grails.mail.default.from="user@gmail.com"

dataSource.dbCreate = "update"
dataSource.url = "jdbc:h2:file:/var/lib/rundeck/data/rundeckdb;MVCC=true;TRACE_LEVEL_FILE=4"

grails {
  mail {
        host = "smtp.gmail.com"
        username = "user@gmail.com"
        port = 465
        password = "password"
        props = ["mail.smtp.auth":"true",
                "mail.smtp.port":"465",
                "mail.smtp.starttls.enable":"true",
                "mail.smtp.socketFactory.port":"465",
                "mail.smtp.socketFactory.fallback":"false"]
  }
}
grails.serverURL="https://rundeck-server:4443"
rundeck.log4j.config.file = "/etc/rundeck/log4j.properties"

如果使用端口465运行它,则会收到以下错误。

2019-01-03 14:57:26.260 ERROR --- [eduler_Worker-1] rundeck.services.NotificationService     : Error sending notification email to user@gmail.com for Execution 231: Mail server connection failed; nested exception is javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465, response: -1. Failed messages: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465, response: -1

如果使用端口587进行配置,则会在“ /var/log/rundeck/service.log”中收到以下错误消息

2019-01-03 15:05:52.121 ERROR --- [eduler_Worker-1] rundeck.services.NotificationService     : Error sending notification email to user@gmail.com for Execution 233: Mail server connection failed; nested exception is javax.mail.MessagingException: Could not convert socket to TLS;
  nested exception is:
	javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target. Failed messages: javax.mail.MessagingException: Could not convert socket to TLS;
  nested exception is:
	javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

或者,我安装了mailx,尽管日志中有错误,但是当我运行以下“ echo“ Your message” | mail -v -s“ Message Subject” user@gmail.com“命令时,它成功发送了一封电子邮件。输出是

Resolving host smtp.gmail.com . . . done.
Connecting to x.x.x.x:465 . . . connected.
Error in certificate: Peer's certificate issuer is not recognized.
Comparing DNS name: "smtp.gmail.com"
SSL parameters: cipher=AES-xxx-GCM, keysize=xxx, secretkeysize=xxx,
issuer=CN=Google Internet Authority G3,O=Google Trust Services,C=US
subject=CN=smtp.gmail.com,O=Google LLC,L=Mountain View,ST=California,C=US
220 smtp.gmail.com ESMTP b22sm9658588ios.45 - gsmtp
>>> EHLO rundeck-server
250-smtp.gmail.com at your service, [x.x.x.x]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
>>> AUTH LOGIN
334 xxxx
>>> xxxx==
334 xxxx
>>> xxxx==
235 2.7.0 Accepted
>>> MAIL FROM:<user@rundeck-server>
250 2.1.0 OK xx - gsmtp
>>> RCPT TO:<user@gmail.com>
250 2.1.5 OK xx - gsmtp
>>> DATA
354  Go ahead xx - gsmtp
>>> .
250 2.0.0 OK xx - gsmtp
>>> QUIT
221 2.0.0 closing connection xx - gsmtp

我在“ /etc/mail.rc”文件的底部添加了以下内容

set smtp=smtps://smtp.gmail.com:465
set smtp-auth=login
set smtp-auth-user=USER.GMAIL.COM
set smtp-auth-password='password'
set ssl-verify=ignore
set nss-config-dir=/etc/pki/nssdb/

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

我使用 /etc/rundeck/rundeck-config.groovy 中的这些设置从我的 Gmail 帐户发送电子邮件

grails {
  mail {
        host = "smtp.gmail.com"
        username = "USER"
        port = 587
        password = "PASSWORD"
        props = ["mail.smtp.starttls.enable":"true","mail.smtp.auth":"true","mail.smtp.socketFactory.port":"587","mail.smtp.socketFactory.fallback":"false"]
  }
}