无法从ubuntu 16上的php脚本发送邮件[重复]

问题描述 投票:0回答:1

这个问题在这里已有答案:

我有一个PHP脚本来发送一个不能在ubuntu服务器上运行的邮件。但是从服务器登录后如果我触发此命令

echo "body" | mail -s "subject" root 

然后它工作正常..我也能够从这个命令接收电子邮件,但不能使用代码中的脚本

谁能告诉我我在做什么错?

这是我发送电子邮件的PHP脚本:

<html>

<head>
<title>Sending HTML email using PHP</title>
</head>

<body>

<?php

$to = "[email protected]";
$subject = "This is subject";

$message = " Testing email service from my website. ";


$header = "From: [email protected] \r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html\r\n";

$retval = mail ($to,$subject,$message,$header);

if( $retval == true ) {
echo "Message sent successfully ...";
}else {
echo "Message could not be sent...";
}
?>

</body>
</html>
php email ubuntu
1个回答
0
投票

在php.ini文件中,你必须配置php应该如何发送邮件。您可以使用sendmail并在那里配置SMTP。

© www.soinside.com 2019 - 2024. All rights reserved.