Jump to content

Help with intermittent form submission not being received


damion

Recommended Posts

I have a site that allows people to register for a fee. It is a very basic form asking for name and contact info.

After they fill out the form and submit it, they are brought to paypal to make their payment. After paying, the form data is sent to the admin and to the customer.

What is very strange is the form seems to work perfectly most of the time, except sometimes:

1. the email is not received by the admin (not sure if the buyer is getting their copy though).

2. if multiple email addresses in the admin settings to receive it (comma separated), sometimes some receive it, but some do not!

 

The owner of the site said they do check their spam and we've tried different email addresses for the admin (gmail, outlook, yahoo, etc..) and it has occurred on all of them, no rhyme or reason.

 

Do you see anything wrong with my form below that would have this intermittent issue?

 

Also, anyone suggest how I can add headers to this so that the 'from' won't default to the host server name?

 

The file admin.php contains the email variable $admin_email

<?php
require '../admin.php';
session_start();
if (!isset($_SESSION['order_id']) || empty($_SESSION['order_id'])) {
	header('Location: ../../');
}

// admin email
mail($admin_email, 'Website form submitted', 'Visitor information.
Registration: ' . $_SESSION['order_id']."\r\n".'
First Name: ' .$_SESSION['fname'].'
Last Name: ' .$_SESSION['lname'].'
Email: ' .$_SESSION['email'].'
Phone: ' .$_SESSION['phone']);

// visitor email
$to = $_SESSION['email'];
mail($to, 'Thank you for registering', 'Review your submission below.
Please contact us if you need further assistance.
Registration: ' . $_SESSION['order_id']."\r\n".'
First Name: ' .$_SESSION['fname'].'
Last Name: ' .$_SESSION['lname'].'
Email: ' .$_SESSION['email'].'
Phone: ' .$_SESSION['phone']);

session_destroy();
?>
Link to comment
Share on other sites

Hi there,

 

This isn't an answer to your issue, but I'm wondering if you could assign the mail function to a variable and then test the variable to see if sent... this may help with debugging the issue (it also may not).

 

I'd do something like:

 

// admin email 
$send_admin_email = mail($admin_email, 'Website form submitted', 'Visitor information. Registration: 
' . $_SESSION['order_id']."\r\n".' First 
Name: ' .$_SESSION['fname'].' Last 
Name: ' .$_SESSION['lname'].' Email: 
' .$_SESSION['email'].' Phone: 
' .$_SESSION['phone']);
if ($send_admin_email) 
{ 
	//the mail function worked
}





 

I realise this doesn't answer your question, but it may help you debug if you blast a few emails out and check the values of the ones that fail.

 

Good luck.

Link to comment
Share on other sites

 

I actually tried to follow that before (and also tried example #3). The problem I was having when trying to implement them was that they were appearing literally in the email as text. And of course since it was not parsing it did not change the 'from'. How would you go about adding it in my case? Can you show me?

 

Thanks

Link to comment
Share on other sites

Hi there,

 

This isn't an answer to your issue, but I'm wondering if you could assign the mail function to a variable and then test the variable to see if sent... this may help with debugging the issue (it also may not).

 

I'd do something like:

 

// admin email 
$send_admin_email = mail($admin_email, 'Website form submitted', 'Visitor information. Registration: 
' . $_SESSION['order_id']."\r\n".' First 
Name: ' .$_SESSION['fname'].' Last 
Name: ' .$_SESSION['lname'].' Email: 
' .$_SESSION['email'].' Phone: 
' .$_SESSION['phone']);
if ($send_admin_email) 
{ 
	//the mail function worked
}





 

I realise this doesn't answer your question, but it may help you debug if you blast a few emails out and check the values of the ones that fail.

 

Good luck.

 

Hmm... I'm going to play around with that. But maybe I won't make it send an email if the condition is true :)

I'm almost convinced the problem is the user not finding the email in their spam. Every test I ran with my email addresses plugged in I always got them! But I need to be sure, and it's a very aggravating and time consuming issue.

 

Thanks!

Link to comment
Share on other sites

Do you have php error checking enabled to be sure your script is free of errors?

 

As for testing the result of the mail call - I find that it pretty much always comes back true even if the mail is never sent.

 

As for the headers showing up in the message - you probably did not format the mail call correctly. Try building the message body from all those parts outside of the call and then just pass in 4 vars to the call: $to, $subject, $msg, $hdrs.

Link to comment
Share on other sites

Do you have php error checking enabled to be sure your script is free of errors?

 

As for testing the result of the mail call - I find that it pretty much always comes back true even if the mail is never sent.

 

As for the headers showing up in the message - you probably did not format the mail call correctly. Try building the message body from all those parts outside of the call and then just pass in 4 vars to the call: $to, $subject, $msg, $hdrs.

 

Ah, thanks for the tip about error checking. It seems that when my form is submitted the page it submits to contains 2 warnings and 1 notice.

The notice is an undefined variable, and the warnings are for headers already sent. The problem is the header-location is in 2 areas of my page in If statements and I don't know how to get around that.

Link to comment
Share on other sites

The way to avoid a problem with headers is to practice good code organization in your scripts. Do your output from one place, after you have processed thru all your logic. That way if your logic wants to send you somewhere else it can do so, since you will not have output anything at that point.

 

Fix those errors!

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.