我正在尝试建立一个系统,向客户发送包含单选按钮和提交按钮的电子邮件,然后将其指向包含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地址没有收到任何邮件。如果有人有任何建议,请帮助,因为这会变成一场噩梦。