Linux configuration — ssmtp: Cannot open smtp.gmai

2019-04-06 15:15发布

Hi I have RHEL5 with ssmtp installed on it ssmtp-2.61-22.el5.i386.rpm

my /etc/ssmtp/ssmtp.conf updated as below :-

AuthUser=mymail@gmail.com
AuthPass=mypassword
FromLineOverride=YES
mailhub=smtp.gmail.com:587
UseSTARTTLS=YES
UseTLS=Yes
RewriteDomain=gmail.com

also revaliases updated as below :

root:mymail@gmail.com:smtp.gmail.com:587

i have shutdown sendmail service

when i try to send email with ssmtp i get below error

[root@ctmtest ssmtp]# echo "test" | ssmtp -vvv mymail@gmail.com
[<-] 220 smtp.gmail.com ESMTP v26sm42795996pfi.56 - gsmtp
[->] EHLO ctmtest
[<-] 250 SMTPUTF8
[->] STARTTLS
[<-] 220 2.0.0 Ready to start TLS
ssmtp: Cannot open smtp.gmail.com:587

i searched lots of tag with this error , but unable to fix this

my system is able to connect smtp.gmail.com on port 587

[root@ctmtest ssmtp]# telnet smtp.gmail.com 587
Trying 74.125.200.108...
Connected to smtp.gmail.com (74.125.200.108).
Escape character is '^]'.
220 smtp.gmail.com ESMTP o90sm11695907pfi.17 - gsmtp

is there anyone who have fixed this ? please suggest

5条回答
姐就是有狂的资本
2楼-- · 2019-04-06 15:56

try changing this option

Allowing less secure apps to access your account

https://support.google.com/accounts/answer/6010255?hl=en

查看更多
啃猪蹄的小仙女
3楼-- · 2019-04-06 15:58

On my Gentoo Linux system, the error ssmtp: Cannot open smtp.server.com:port was caused by an ownership/permissions issue: the file /etc/ssmtp/ssmtp.conf should belong to the group ssmtp, which it didn't (and any user allowed to access ssmtp should be a member of that group).

查看更多
老娘就宠你
4楼-- · 2019-04-06 16:08

I encountered the same problem. The following steps worked for me:

  1. sudo vi/etc/ssmtp/ssmtp.conf Add the following:

TLS_CA_FILE=/etc/pki/tls/certs/ca-bundle.crt root=XXXX@gmail.com mailhub=smtp.gmail.com:587 AuthUser=XXXX AuthPass=XYXYX UseSTARTTLS=Yes UseTLS=Yes hostname=AAAA

Replace: XXXX- username(mail) XYXYX- password(mail password) AAAA- hostname(get by running $hostname)

  1. sudo vi /etc/ssmtp/revaliases Add the following:

root:XXXX@gmail.com:smtp.gmail.com:587

Replace : XXXX - username(mail)

  1. Try running the mail now:

    $mail -s "adasdas" XXXX@gmail.com

    CC: XYZLoremIpsum . 'ctrl+D'

It solved my problem. Hopefully for a system(Office) you need to configure correct proxy settings otherwise you will get an error:

cannot send message: Process exited with a non-zero status

查看更多
叼着烟拽天下
5楼-- · 2019-04-06 16:13

This is perhaps because you're not setting the hostname parameter of ssmtp.conf. It should be a resolvable, fully-qualified domain name; yours is defaulting to the machine name of ctmtest (as shown in the EHLO command that you quote above).

The issue that user963 mentions in their answer may also be in action here, but in that case you'll get a different error message, something like ssmtp: Authorization failed (534 5.7.14 ...).

查看更多
ゆ 、 Hurt°
6楼-- · 2019-04-06 16:20

first to get your hostname type in terminal : hostname

copy it and past in hostname parameter in ssmtp.conf

查看更多
登录 后发表回答