简体   繁体   English

无法从ubuntu服务器中的php应用程序发送邮件

[英]Unable to send mail from php application in ubuntu server

Recently I moved a PHP application from a linux server to a linux Ubuntu 3.6 server and the version of PHP in the 最近,我将PHP应用程序从linux服务器移到了Linux Ubuntu 3.6服务器,并且将PHP的版本移到了Linux中。

old server = 5.4
ubuntu 3.6 = 5.3.6-13

but now the mail application is not working in ubuntu server but below command returns true: 但现在邮件应用程序无法在ubuntu服务器中运行,但以下命令返回true:

if(mail('abc@xyz.com', 'test-subject', 'test-text-blablabla'))
   echo 'ok';
else
   echo 'bad';

I came to know while googling that we need to make changes in some php.ini file but I dont no where exactly I need to make changes. 我在谷歌搜索时才知道我们需要在一些php.ini文件中进行更改,但是我不确切地需要进行更改。

Can any one help me out to solve little question please ? 有人可以帮我解决一点问题吗?

Just a quick view of your mail function, you are missing the "from" field no? 只是快速浏览一下邮件功能,您是否缺少“发件人”字段? My personal thoughts would be to use something like PHPMailer or SwiftMail and see if you can use an SMTP server too (not required to use SMTP server though). 我个人的想法是使用类似PHPMailer或SwiftMail的工具,看看您是否也可以使用SMTP服务器(尽管使用SMTP服务器不是必需的)。 They provide an error response which would defo help you. 他们提供了错误响应,可以帮助您。

Refer to the PHP Mail() link on php.net and create some headers as the example below shows: 请参考php.net上的PHP Mail()链接并创建一些标头,如下例所示:

<?php
$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>

您是否配置了新服务器,以便通过安装诸如nullmailer,sendmail或其他软件包来将电子邮件重定向到实际的smtp服务器?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM