1

我正在尝试建立一个系统,向客户发送一封包含单选按钮和提交按钮的电子邮件,然后将他们定向到包含 PHP 的 Wordpress 页面,然后该页面将向我们的支持团队发送一封包含详细信息的电子邮件。我已经在 wordpress 上安装了 exec_php 并使用了从我在网上找到的那些修改的 PHP 脚本,但是尽管检查了我能想到的所有内容,它仍然没有发回电子邮件,尽管有一些 PHP 正在执行。

wordpress 页面上的 PHP:

<?php if($_SERVER["REQUEST_METHOD"] == "POST")
{
$to = "example@gmail.com";
$from = "no-reply@oursite.co.uk";
$resolved = $_POST['yesno'];
if ($resolved=='This issue was resolved.')
{$body = $_POST['cust'] . "has responded to an email asking for feedback regarding the closure of case number" . $_POST['casesendid'] . "The person in question responded that they are satisfied with the resolution. Please do not reply to this email.";}
else
{$body= $_POST['cust'] . "has responded to an email asking for feedback regarding the closure of case number" . $_POST['casesendid'] . "The person in question responded that they are not satisfied with the resolution. Please do not reply to this email.";}
$subject = "Automated Feedback Message";
$SMTPMail = new SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body);
$SMTPChat = $SMTPMail->SendMail();
}
echo $resolved;
?>

该页面的模板包含php包含到同一目录中的两个文件,在“settings.php”中:

<?php
//Server Address
$SmtpServer="smtp.hosts.co.uk";
$SmtpPort="25"; //default
$SmtpUser="oursite.co.uk";
$SmtpPass="password";
?>

在 mailclass.php 中:

<?php
class SMTPClient
{

function SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body)
{

$this->SmtpServer = $SmtpServer;
$this->SmtpUser = base64_encode ($SmtpUser);
$this->SmtpPass = base64_encode ($SmtpPass);
$this->from = $from;
$this->to = $to;
$this->subject = $subject;
$this->body = $body;

if ($SmtpPort == "")
{
$this->PortSMTP = 25;
}
else
{
$this->PortSMTP = $SmtpPort;
}
}

function SendMail ()
{
if ($SMTPIN = fsockopen ($this->SmtpServer, $this->PortSMTP))
{
fputs ($SMTPIN, "EHLO ".$HTTP_HOST."\r\n");
$talk["hello"] = fgets ( $SMTPIN, 1024 );
fputs($SMTPIN, "auth login\r\n");
$talk["res"]=fgets($SMTPIN,1024);
fputs($SMTPIN, $this->SmtpUser."\r\n");
$talk["user"]=fgets($SMTPIN,1024);
fputs($SMTPIN, $this->SmtpPass."\r\n");
$talk["pass"]=fgets($SMTPIN,256);
fputs ($SMTPIN, "MAIL FROM: <".$this->from.">\r\n");
$talk["From"] = fgets ( $SMTPIN, 1024 );
fputs ($SMTPIN, "RCPT TO: <".$this->to.">\r\n");
$talk["To"] = fgets ($SMTPIN, 1024);
fputs($SMTPIN, "DATA\r\n");
$talk["data"]=fgets( $SMTPIN,1024 );
fputs($SMTPIN, "To: <".$this->to.">\r\nFrom: <".$this->from.">\ \nSubject:".$this->subject."\r\n\r\n\r\n".$this->body."\r\n.\r\n");
$talk["send"]=fgets($SMTPIN,256);
//CLOSE CONNECTION AND EXIT ...
fputs ($SMTPIN, "QUIT\r\n");
fclose($SMTPIN);
//
}
return $talk;
}
}
?>

所有密码和用户名字段都填充了我们的实际详细信息,当重定向到页面时,会显示 $resolved 的正确值,暗示 php 确实执行了,但是 $to 地址从未收到任何邮件。如果有人有任何建议,请提供帮助,因为这正在变成一场噩梦。

4

0 回答 0