Jump to content

Problem with sendmail script


soyuz02

Recommended Posts

Hi guys,

 

Trying to customise a website template which has a contact us form and uses a php sendmail script.

 

Problem is I'm not receiving any emails sent through it.

 

I've run a basic php sendmail script so see whether the server allows it nd that works fine hence it must be the script

 

Any help much appreciated!

 

Thanks!

 

<?php
if($_REQUEST['first_name'] == '' || $_REQUEST['contact_email'] == '' ||  $_REQUEST['message'] == ''):
  return "error";
endif;
if (filter_var($_REQUEST['contact_email'], FILTER_VALIDATE_EMAIL)):
  $subject = 'Contact from Webpage'; // Subject of your email
 
  // Receiver email address
  $to = '[email protected]';  //Change the email address by yours
 
 
  // prepare header
  $header = 'From: '. $_REQUEST['first_name'] . " " .$_REQUEST['last_name'] . ' <'. $_REQUEST['contact_email'] .'>'. "\r\n";
  $header .= 'Reply-To:  '. $_REQUEST['first_name'] . " " .$_REQUEST['last_name'] . ' <'. $_REQUEST['contact_email'] .'>'. "\r\n";
  // $header .= 'Cc:  ' . '[email protected]' . "\r\n";
  // $header .= 'Bcc:  ' . '[email protected]' . "\r\n";
 
 
  $message .= 'Name: ' . $_REQUEST['first_name'] . " " .$_REQUEST['last_name'] . "\n";
  $message .= 'Email: ' . $_REQUEST['contact_email'] . "\n";
  $message .= 'Subject: ' . $_REQUEST['contact_subject'] . "\n";
  $message .= 'Message: '. $_REQUEST['message'];
 
  // Send contact information
  mail($to, $subject, $message, $header);
 
  echo 'sent';
  else:
    return "error";
  endif; 
 
?>
Link to comment
https://forums.phpfreaks.com/topic/296341-problem-with-sendmail-script/
Share on other sites

You state that it isn't sending the email. Is that because you don't receive one or because you get your error message? Would be nice to know.

 

Debugging info for next post:

1 - post any code you have in the proper tags for this forum such as 'code' and '/code' in square brackets

 

2 - Show us the contents of the mail vars so we can see what you have built.

 

3 - turn on php error checking

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.