Jump to content

php mail() returns false !?


pokernarr

Recommended Posts

first:  Hi to all of you! Im new to this forum and registered because i had the following problem with the mail()-function

i used the same code (header-code and mail-code) in another form where everything works well.. var_dumping the mail()'s result returns false (so its no mailer-side issue)

What else shall i try? (i also tried \r\n instead of \n-only in the header-code)

 

<?php

  $name = $sex."<br />".$name;
  $content = "";
  
  if (isset($_POST['c1'])) {$content .= check_input($_POST['c1'])."<br />";}
  if (isset($_POST['c2'])) {$content .= check_input($_POST['c2'])."<br />";}
  if (isset($_POST['c3'])) {$content .= check_input($_POST['c3'])."<br />";}
  if (isset($_POST['c4'])) {$content .= check_input($_POST['c4'])."<br />";}
  if (isset($_POST['c5'])) {$content .= check_input($_POST['c5'])."<br />";}
  if (isset($_POST['c6'])) {$content .= check_input($_POST['c6'])."<br />";}
  if (isset($_POST['c7'])) {$content .= check_input($_POST['c7'])."<br />";}
  if (isset($_POST['c8'])) {$content .= check_input($_POST['c8'])."<br />";}
  if (isset($_POST['c9'])) {$content .= check_input($_POST['c9'])."<br />";}
  
  $string = "<div>".$name."<br />".$adress."<br />".$_POST['phone']."<br />".$email_from."</div>";
  $string .= "<br /><p /><table width='100%' cellspacing='0' cellpadding='0'><tr><th valign='top' width='25%'>Ihr Wunschtermin</th><th valign='top' width='25%'>Alternative</th><th width='25%' valign='top'>Trainingsart</th><th valign='top'>Inhalte</th></tr>";
  $string .= "<tr><td colspan='4'><hr></td></tr>";
  $string .= "<tr align='center'><td valign='top'>".$date1."</td><td valign='top'>".$date2."</td><td valign='top'>".$training."</td><td valign='top'>".$content."</td></tr>";
  $string .= "<tr><td colspan='4'><hr></td></tr>";
  $string .= "<tr><td colspan='4' align='left'><b>Anmerkung:</b> ".$comments."</td></tr>";
  $string .= "</table>";


  $email_content = $name . "\n" . $adress . "\n" . $_POST['phone'] . "\n" . $email_from . "\n\n\nWunschtermin: " . $date1 . "\nAlternative: " . $date2 . "\n\n" . $training . "\n" . $content . "\n\n\nAnmerkung: " . $comments;
  
                        ////// HERE WE GOO :

  // create email headers
  $headers = 'From: ' . $email_from . "\n".
  'Reply-To: '.$email_from ."\n" .
  'X-Mailer: PHP/' . phpversion();
  $result = mail($email_to, "Terminanfrage ".$date1, $email_content, $headers);
  
  var_dump($result);
  
  echo "<H4> Ihre Anfrage wurde abgesendet und wird in Kürze bearbeitet.</h4><p />Sollten Sie Fragen oder Anregungen haben, <a href='contact.html'>schreiben Sie uns!</a> Sie erhalten in den nächsten Tagen eine Bestätigung, oder im Falle einer Absage den Grund und einen neuen Terminvorschlag.<p />Ihre Angaben im Überblick:<p />";
  echo $string;
  echo "<div style='height:150'></div>";
?>

Link to comment
Share on other sites

yes, as i said exactly the same code is working at the same server on another .php-page.

 

I am fairly new to PHP and scripting in general (actually i only used AutoIT efficiently so far) that i don't know where to search for to get this fixed. The help file on mail() gave no information. 

 

$header  and  $email_to  are both fine.    the $subject param should be ($date1 is a string like '19.06.1999'  ).  $email_content used to be html-code, but i formatted it into a string just to see if something happens. Nothing happened.

Link to comment
Share on other sites

I don't know of any documented behavior of PHP doing this.

 

Unless there's some sort of htaccess restriction or CRAZY outside configuration, there's no way a built in function should work on one page, and not the other.

 

I don't think it's possible to get this behavior on two files in the same directory.

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.