Jump to content

Recommended Posts

Hi everyone. I'm a newbie. I know pathetically little about php and therefore this is driving me nuts.

 

I'm facing two errors on my website, both of which involves email functions using a php script. The first involves visitors filling out their name and email address, and the server sending this information to my email. The code on the page the visitors are taken to after clicking submit is something like that:

 

<script language="php">

$EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); 
$EmailTo = "addy@mail.com";
$Subject = "Mailing List";
$Name = Trim(stripslashes($_POST['Name'])); 

// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;
}

// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";

// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page 
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=main_pg2.htm\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}

</script>

 

However, even though the correct page shows, I NEVER receive the email. I suspect this may lie with my php.ini file.... of which details can be viewed http://www.lifestorydesigns.com/version.php. But of course, due to my pathetic ability to grasp php, I simply cannot figure out what's wrong or lacking.

 

I've a similar problem with my shopping cart order forms. The orders simply doesn't get emailed to me. I previously never had this problem, so I'm suspecting my server changed some settings in the php.ini etc. Anybody could spare the time to enlighten me PLEASE?

 

Thanks a million!

Link to comment
https://forums.phpfreaks.com/topic/51070-help-needed-to-send-email-via-php/
Share on other sites

No it's not a free server. I pay for the use of hosting my website on it. It's running on Linux. It has all the while been working fine... then suddenly awhile ago, the emails function stop working. I'm suspecting the server may have changed some settings, because I didn't change anything to my scripts.

 

I did notice while looking through the php.ini settings on http://www.lifestorydesigns.com/version.php that under configuration, the sendmail_from denotes "no value", but the sendmail_path denotes "/usr/sbin/sendmail -t -i". Not sure if this is of any consequence....

Here's the full code after I did the adjustment to the header section

 

<?php

$EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); 
$EmailTo = "enquiries@lifestorydesigns.com";
$Subject = "Mailing List";
$Name = Trim(stripslashes($_POST['Name'])); 

// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;
}

// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";

// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page 
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=main_pg2.htm\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}

?>

 

Can anyone help pretty please?? I really cannot see what's wrong with it...

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.