dongmu3269 2016-06-08 11:11
浏览 31

发送电子邮件的Php文件未正确执行

Website source:http://www.salefee.com/

Please check out this website. I have made a form to enter email address under "To recieve the salefee story ebook,submit your email id". This form will redirect to php file named as story.php file. This php file is programmed to send email to admin.

The problem is that when user clicks submit button it is redirected to url http://www.salefee.com/story.php and a blank page appears and I am not getting automated mail. My story.php file is as follows:

<?php
if ($_POST) {
  $to_email = "salefee12@gmail.com" //Recipient email, Replace with own email here


  //Sanitize input data using PHP filter_var().
   $user_trial_email   = filter_var($_POST["trial-email"], FILTER_SANITIZE_EMAIL);

  //additional php validation
 if (!filter_var($user_trial_email, FILTER_VALIDATE_EMAIL)) { //email validation
    $output = json_encode(array('type'=>'error', 'text' => 'Please enter a valid email.'));
    die($output);
  }

  //subject
  $subject = "The Story";
  $user_trial_name = "salefee12@gmail.com"
  $user_trial_phone = "1234567890"

  //email body
  $message_body = "Name   : ".$user_trial_name."
Email  : ".$user_trial_email."
Phone  : ".$user_trial_phone."
App link:https://play.google.com/apps/testing/com.salefee.salefee.salefee";


  //proceed with PHP email.
  $headers = 'From: '.$user_trial_name.''."
".
  'Reply-To: '.$user_trial_email.''."
".
  'X-Mailer: PHP/'.phpversion();

  $send_mail = mail($to_email, $subject, $message_body, $headers);

  if (!$send_mail)
  {
    //If mail couldn't be sent output error. Check your PHP email configuration (if it ever happens)
    $output = json_encode(array('type'=>'error', 'text' => 'Could not send mail! Please check your PHP mail configuration.'));
    die($output);
  } else {
    $output = json_encode(array('type'=>'message', 'text' => 'Hi '.$user_trial_name.', Thank you for subscribing. You will soon get a link to download app.'));
    die($output);
  }
}
?>

My form in html file is as follows:

<!-- Mailchimp Newsletter -->
              <div class="newsletter-wrapper animateblock rtl-2 speed-1">
              <form action="story.php" method="post">
              <div class="form-group input-group input-newsletter" style="width:400px;margin: 0 auto;">
              <input class="form-control" id="trial-email" name="trial-email" type="email" required autocomplete="on" placeholder="Enter email" style="border-color:#D9534F;">
              <div class="input-group-btn">
              <button class="btn btn-danger" type="submit">click me</button>
              </div>
              </div>
              </form>
              </div>
              </div>

              <!-- End Mailchimp Newsletter -->

I have used similar php code in other 2 forms on my website. Those other 2 forms are working properly(I am getting mail). But this php code is not working.

Please help me this code. Guide me how to debug this code or how to print a message on browser so that I can understand till where my code is running properly. Thanks in advance.!!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题
    • ¥15 lna设计 源简并电感型共源放大器