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 = 'info@test.co.uk';  //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:  ' . 'example@domain.com' . "\r\n";
  // $header .= 'Bcc:  ' . 'example@domain.com' . "\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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.