1

我已经在我的本地机器上安装了 LAMP,现在我正在寻找添加 PHP 邮件,但是我运气不佳。

我已经安装了 postfix,我的 /etc/postfix/main.cf 如下所示:

myhostname = my_computer_name (is this ok?)
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = my_domain_name, my_computer_name, localhost.localdomain, localhost
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all

有人可以告诉我我错过了什么吗?myhostname 应该是我的计算机名称还是其他名称?与我的目的地相同。它需要中继主机吗?

干杯

4

2 回答 2

0

做一个 php 信息以查看安装的内容

http://php.net/manual/en/function.phpinfo.php

遵循像这样的真正回归基础示例(确定它是基于代码还是基于配置)

<?php
$to = "somebody@example.com";
$subject = "My subject";
$txt = "Hello world!";
$headers = "From: webmaster@example.com" . "\r\n" .
"CC: somebodyelse@example.com";

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

根据我的经验,它通常是开箱即用的,您可能需要在此处调查此链接之类的其他内容:

http://email.about.com/od/emailprogrammingtips/qt/Configure_PHP_to_Use_a_Local_Mail_Server_for_Sending_Mail.htm

于 2012-08-20T14:45:37.717 回答
0

php mail use your system MTA (Mail Transfer Agent), it is Postfix in your case. So you have to configure correctly postfix first. It is not easy to configure because when your server send an email, the recipient mail server can block it (antispam filter) for many reason and one for the reason is your hostname not matching your server ip.

于 2012-08-20T14:53:23.187 回答