如何设置smtp并发送邮件?

如何设置smtp并发送邮件?

我是树莓派新手。

我在上面安装了raspian操作系统。我想使用我的 Gmail 帐户从它发送电子邮件。我想从命令行界面和 php 脚本发送。

我遵循了这个指南。 http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/

我从链接中执行了步骤 1、2、3、4。

当我使用下面的代码发送电子邮件时

echo "Test text" | mail -s "Test Mail" [email protected]

什么也没发生,屏幕上没有打印任何内容,我也没有收到电子邮件。

在“revaliases”上,如果我用“smtp.gmail”替换“mail.google”,那么我会收到一条消息说

send-mail: Cannot open mail.google.com:587

或者

send-mail: Server didn't like our AUTH LOGIN (530 5.7.0 Must issue a STARTTLS command first. ml2sm3592928igb.10 - gsmtp)

我怎样才能解决这个问题?

这是下面的两个文件:

ssmtp.conf

#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
# root=postmaster

# The place where the mail goes. The actual machine name is required no 
# MX records are consulted. Commonly mailhosts are named mail.domain.com
# mailhub=mail

# Where will the mail seem to come from?
#rewriteDomain=

# The full hostname
hostname=raspberrypi

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES


[email protected]
mailhub=smtp.gmail.com:587
[email protected]
AuthPass=mypass
UseSTARTTLS=YES

重新定义

# sSMTP aliases
# 
# Format:   local_account:outgoing_address:mailhub
#
# Example: root:[email protected]:mailhub.your.domain[:port]
# where [:port] is an optional port number that defaults to 25.

root:[email protected]:mail.google.com:587

相关内容