du512053619 2016-02-05 02:34
浏览 44
已采纳

PHP邮件脚本只通过电子邮件发送一个地址[重复]

I have this PHP script that links in with a CRM, but the email doesn't send to the admin address; it only sends to the email address that the user puts in (their own email address). It does not send to the ADMIN EMAIL.

Here's the script. Any help would be great; I didn't write this and I haven't been in the job long!

<?php
$parameter = $_GET;
$query = http_build_query($parameter, '', '&');
$url = "CRM Address";
$url .= "?".$query; 

$headers = "MIME-Version: 1.0" . "
";
$headers .= "Content-type:text/html;charset=UTF-8" . "
";
$headers .= 'From: FROM EMAIL' . "
" ;

$to = $_GET['Emailaddress'];
$subject = "Thank you";
$message = '

';

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

$ch=curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
$result = curl_exec($ch);
curl_close($ch);

$message2 = "";
foreach ($parameter as $k => $s){
    $message2 .= "<p>".$k." : ".$s."</p>";
}   
$to = "ADMIN EMAIL";
$subject2 = "Enquire";
mail($to2, $subject2, $message2, $headers);

if($result){
    header('Location:REDIRECT');
    }
?>
</div>
  • 写回答

1条回答 默认 最新

  • douzhi1972 2016-02-05 02:38
    关注

    Look carefully at your script, especially this part:

    $to = "ADMIN EMAIL";
    $subject2 = "Enquire";
    mail($to2, $subject2, $message2, $headers);
    

    You set $to, but send the email to $to2. Change your script to

    $to2 = "ADMIN EMAIL"; // fix the variable name
    $subject2 = "Enquire";
    mail($to2, $subject2, $message2, $headers);
    

    This is a good illustration why you:

    1. Should use an IDE and a debugger.
    2. Should never just use scripts you got from the Internet if you don't understand them.
    3. Should use descriptive variable names, not $foo and $foo2.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#vscode#的问题:ESP32开发板对接MQTT实现小灯泡的开关
  • ¥15 TMC2209串口模式下读取不到寄存器的值串口助手蓝色字体是发过去的消息,绿色字体是收到的消息,第二行发送读取寄存器的指令但是没有读取到寄存器的值串口助手如下图:接线如下图,如何解决?
  • ¥15 高通安卓11提取完整线刷包软件,或者优博讯dt50顺丰刷机包
  • ¥20 C,有个译码器,换了信道就跑不出原来数据
  • ¥15 MIMIC数据库安装问题
  • ¥60 基于JTag协议开发Fpga下载器上位机,哪位大🐂有偿指导?
  • ¥20 全书网Java爬取数据
  • ¥15 怎么获取红包封面的原始链接,并且获取红包封面序列号
  • ¥100 微信小程序跑脚本授权的问题
  • ¥100 房产抖音小程序苹果搜不到安卓可以付费悬赏