Jump to content

Help needed to send email via php


tsachu

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 = "[email protected]";
$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 = "[email protected]";
$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...

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.