ubuntu安装发邮件

参考:https://www.centos.bz/2017/07/ubuntu-install-postfix-mail-server/
安装:

sudo apt-get install postfix -y

安装之后在25端口监听。
直接使用sendmail发送邮件。

echo "test from `uname -a`"|sendmail [email protected]

在垃圾邮箱中查看:
ubuntu安装发邮件_第1张图片

配置好postfix之后,就可以创建用户时,收到邮件了(虽然是在垃圾邮箱里)。
ubuntu安装发邮件_第2张图片

安装postfix之前出现:sh: 1: /usr/sbin/sendmail: not found,安装之后则可以发送成功。

php > $to = "cqq@localhost";
php > $sub = "Test email";
php > $header = "From: dest@localhost"
php > $body = "Hello, dest!";
PHP Parse error:  syntax error, unexpected '$body' (T_VARIABLE) in php shell code on line 2
php > $body = 'Hello, dest!';
php > $sender = "admin@localhost";
php > mail($to, $sub, $body, $header, "-f $sender");
PHP Notice:  Undefined variable: header in php shell code on line 1
sh: 1: /usr/sbin/sendmail: not found
php > mail($to, $sub, $body, $header, "-f $sender");
PHP Notice:  Undefined variable: header in php shell code on line 1
php > $header = "From: dest@localhost";
php > mail($to, $sub, $body, $header, "-f $sender");
php > exit
You have new mail in /var/mail/cqq
cqq@ubuntu:/var/www/bWAPP$ ll /var/mail/cqq
-rw------- 1 cqq mail 951 Nov 21 02:47 /var/mail/cqq
cqq@ubuntu:/var/www/bWAPP$ cat /var/mail/cqq
From admin@localhost  Wed Nov 21 02:46:04 2018
Return-Path: <admin@localhost>
X-Original-To: cqq@localhost
Delivered-To: cqq@localhost
Received: by ubuntu.localdomain (Postfix, from userid 1000)
	id E1814A05AE; Wed, 21 Nov 2018 02:46:04 -0800 (PST)
To: cqq@localhost
Subject: Test email
X-PHP-Originating-Script: 1000:php shell code
Message-Id: <[email protected]>
Date: Wed, 21 Nov 2018 02:46:04 -0800 (PST)
From: cqq <admin@localhost>

Hello, dest!

From admin@localhost  Wed Nov 21 02:47:32 2018
Return-Path: <admin@localhost>
X-Original-To: cqq@localhost
Delivered-To: cqq@localhost
Received: by ubuntu.localdomain (Postfix, from userid 1000)
	id 30871A05AF; Wed, 21 Nov 2018 02:47:32 -0800 (PST)
To: cqq@localhost
Subject: Test email
X-PHP-Originating-Script: 1000:php shell code
From: dest@localhost
Message-Id: <[email protected]>
Date: Wed, 21 Nov 2018 02:47:32 -0800 (PST)

Hello, dest!

你可能感兴趣的:(Web)