douhezhan5348 2013-03-22 21:05
浏览 46
已采纳

PHP向多个收件人发送电子邮件(标头不发送)

I have an index.html and a contacto.php.

contacto.php is supposedly meant to send the user's info to multiple recipients but it's not sending.

This is my index.html (ignore the javascript)

<form action="contacto.php" method="POST">

        <fieldset style="margin: 0px 0 0 0"; >
<br/><br/>  <br/><br/>  <br/><br/>  <br/><br/>


<input maxlength="255" name="Form testing" size="20" type="hidden" value="Form-name-here" /><br>    

 <input value="Nome" onfocus="if (this.value == 'Nome') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Nome';}" maxlength="255" name="name" size="20" type="text" /><br>

<input value="Telemóvel" onfocus="if (this.value == 'Telemóvel') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Telemóvel';}" id="phone" maxlength="40" name="phone" size="20" type="text" /><br>

<input onfocus="if (this.value == 'Email') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Email';}" value="Email" id="email" maxlength="80" name="email" size="20" type="text" /><br>

<input onfocus="if (this.value == 'Localidade') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Localidade';}" value="Localidade" maxlength="255" name="location" size="20" type="text" /><br>

.

And this is my contacto.php:

<?php
 // Get Data
 $name = strip_tags($_POST['name']);
 $email = strip_tags($_POST['email']);
 $phone = strip_tags($_POST['phone']);
 $location = strip_tags($_POST['location']);

 $headers .="De: Form thingy <examplealpha@someemail.com>";
 $headers .="CC: Mail1 <example1@someemail.com>";
 $headers .=", Mail2 <example2@someemail.com>";

 header("Location: thankyou.html");  //Redirect to Thank You HTML page after email is sent


 // Send message
 mail( "example1@someemail.com", "Formulário Facebook Av. Grátis",
 "Name: $name
Email: $email
Phone: $phone
Location: $location
",
  $headers );
 ?>
  • 写回答

2条回答 默认 最新

  • dqftyn1717 2013-03-22 22:18
    关注

    Change:

    $headers .="De: Form thingy <examplealpha@someemail.com>";
    

    To:

    $headers ="From: Form thingy <examplealpha@someemail.com>";
    

    "De: is not standard as per PHP manual, use "From:....

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

    http://php.net/manual/fr/function.mail.php

    Full code:

    <?php
    // Get Data
    $name = strip_tags($_POST['name']);
    $email = strip_tags($_POST['email']);
    $phone = strip_tags($_POST['phone']);
    $location = strip_tags($_POST['location']);
    
    $headers ="From: Form thingy <examplealpha@someemail.com>";
    $headers .="CC: Mail1 <example1@someemail.com>";
    $headers .=", Mail2 <example2@someemail.com>";
    
    // Send message
    mail( "example1@someemail.com", "Formulário Facebook Av. Grátis",
     "Name: $name
    Email: $email
    Phone: $phone
    Location: $location
    ",
      $headers );
    
    header("Location: thankyou.html");  //Redirect to Thank You HTML page after email is sent
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 用vmmare虚拟机用sentaurus仿真的时候,调用terminal程序,输入swb指令弹出这个,打不开workbench,桌面上面的sentaurus workbench也打不开
  • ¥75 使用winspool.drv的SetPrinter设置打印机失败
  • ¥15 simulink 硬件在环路仿真
  • ¥15 python动态规划:N根火柴摆出的最大数字
  • ¥20 (标签-excel)
  • ¥200 求idea10和MyEclipse7.1
  • ¥20 vb6.0截取当前窗体保存为jpg文件
  • ¥20 苹果手机不使用大疆sdk怎么获取遥控器控制信息或如何接入大疆sdk并且成功上架sdk
  • ¥20 woocommerce 注册按键重定向
  • ¥100 求书法图像文字切割代码