来自地址的php mail(Net/SMTP.php)不起作用



我正在使用php mail(Net/SMTP.php(来处理表单,一切正常,它发送电子邮件,唯一的问题是当我查看收件箱中的电子邮件时,它就像没有发件人一样。您可以在我的程序中看到我设置了发件人地址。我正在使用共享主机,我的共享主机提供商是planethippo。

<?php
ini_set("include_path", '/home/gaborszi/php:' . ini_get("include_path") );
echo htmlspecialchars($_POST['name']);
require 'Net/SMTP.php';
$host = 'localhost';
$from = 'gaborszita@gaborszita.tk';
$rcpt = array('gaborszita@yahoo.com', 'gaborszita@gaborszita.tk');
$subj = "Subject: Test Messagen";
$body = "Name: " . htmlspecialchars($_POST['name']);
/* Create a new Net_SMTP object. */
if (! ($smtp = new Net_SMTP($host))) {
die("Unable to instantiate Net_SMTP objectn");
}
/* Connect to the SMTP server. */
if (PEAR::isError($e = $smtp->connect())) {
die($e->getMessage() . "n");
}
$smtp->auth('gaborszita@gaborszita.tk','mypassword');
/* Send the 'MAIL FROM:' SMTP command. */
if (PEAR::isError($smtp->mailFrom($from))) {
die("Unable to set sender to <$from>n");
}
/* Address the message to each of the recipients. */
foreach ($rcpt as $to) {
if (PEAR::isError($res = $smtp->rcptTo($to))) {
die("Unable to add recipient <$to>: " . $res->getMessage() . "n");
}
}
/* Set the body of the message. */
if (PEAR::isError($smtp->data($subj . "rn" . $body))) {
die("Unable to send datan");
}
/* Disconnect from the SMTP server. */
$smtp->disconnect();

我的收件箱图片

我也在我的服务器上使用 PEAR。我对以下行感到困惑:"$rcpt = array('gaborszita@yahoo.com","gaborszita@gaborszita.tk"(;"。 我有一个类似的代码,使用 $email_to = "one.address@sample.com, two.address@sample.com";并且两个地址都收到一份副本。 我的代码还包括一个 $from_address,它是真正的发件人。该地址是我设置的电子邮件帐户,仅用于向我发送表单数据。

最新更新