如何使用curl命令行程序从gmail帐户发送电子邮件?
我已尝试以下方法:
curl -n --ssl-reqd --mail-from "<sender@gmail.com>" --mail-rcpt "<receiver@server.tld>" --url smtps://smtp.gmail.com:465 -T file.txt
但是,当file.txt作为电子邮件的内容时,当我运行此命令时,我得到以下错误:
curl: (67) Access denied: 530
是否可以从个人服务器托管的帐户发送电子邮件,仍然使用curl?这是否使认证过程更容易?
5条答案
按热度按时间ahy6op9u1#
其他信息:
1.我使用的是支持SSL的
curl
版本7.21.6。1.您不需要使用
--insecure
开关,它会阻止curl
执行SSL连接验证。请参阅this online resource了解更多详细信息。1.通过命令行参数传递帐户凭证被认为是一种不好的安全做法。请使用
--netrc-file
。请参阅the documentation。1.对于安全性较低的应用程序或较新的App passwords,您必须使用turn on access。
r7knjye22#
如果要发送抄送或密件抄送邮件:
第一个
cotxawn73#
创建一个简单的
email.conf
文件,如下所示在使其可执行(
sudo chmod +x sendmail.sh
)后,只需运行sendmail.sh
即可。编码
more
pkwftd7m4#
请注意mail.txt的格式似乎很重要/ CRLF用于win,LF用于Linux,特殊字符等。
最后经过2个小时的挣扎,它为我工作的GMX(他们告诉他们的SMPT端口是587 -并进一步在小写字母的提示:“465也可与SSL一起使用”):
在Linux下(安装了curl.tcz的Raspberry 3B+上的TinyCore Linux):
窗下:
使用mail.txt:
x8goxv8g5#
请注意,如果使用Perl的“
system()
“函数执行curl
命令,则每个参数'word'在参数数组中是单独的项,并且单词不得用引号引起来。另请注意,如果在2022年5月30日之后通过Gmail发送邮件,Gmail账户必须设置双因素身份验证,然后必须创建“应用程序密码”。应用程序密码是一个长字符串,作为替代密码,并取代“
--user
“参数上的常用密码。