1

When a visitor submits the details, a pdf file downloads automatically.

It works well. but I don't understand why this is sending blank emails every day

Appreciated your response and Thanks in advance.

      <?php
$email=$_POST['email'];
$fname=$_POST['fname'];
$lname=$_POST['lname'];
$phone=$_POST['phone'];
$company=$_POST['company'];
$subject='E-Book Downloaded| Research to Revenue'." ". $_POST['subject'];

 $email_from = '$email';

$emailto= "myemail@mail.com";
$emailcc= "myemail@mail.com";

// //replace with your email myemail@mail.com

  $body = 'First Name: ' . $fname . "\n\n" . 'Last Name: ' . $lname  . "\n\n" . 'Company: ' . $company .  "\n\n" . 'Email: ' . $email .  "\n\n" . 'Phone: ' . $phone; 
// 
mail($emailto, $subject, $body, 'From:' . $subject . '');
mail($emailcc, $subject, $body, 'From:' . $subject . '');
// 
// echo json_encode($status);
//
ob_start();
    $file = 'pdf/ResearchtoRevenue.pdf';

     (file_exists($file)) 
    {
        header('Content-Description: File Transfer');
        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename='.basename($file));
        header('Content-Transfer-Encoding: binary');
        header('Expires: 0');
        header('Cache-Control: must-revalidate');
        header('Pragma: public');
        header('Content-Length: ' . filesize($file));
        ob_clean();
        flush();
        readfile($file);
        exit();

}

 die ;
?>
Shri Kurma
  • 11
  • 1
  • Check your server access logs, and track down where that request is coming from. It could be a bot, it could be something else. You should probably make sure the POST variables exist before sending the email. – aynber Jul 10 '17 at 13:31
  • 1
    Also check if any cron is running on your server. – BSB Jul 10 '17 at 13:32

1 Answers1

0

Try to look at this: problem with php mail 'From' header

Probably there is problem with 4th parameter of mail function - headers. I think that 'From:' . $subject is not valid.

teo
  • 801
  • 6
  • 14