Jump to content

why will mail() not send


UserNameIsTaken

Recommended Posts

Please help me this is driving me crazy

 

<?php
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: WebForm <WebForm@RealEstateBram.com>' . "\r\n";
$subject = 'Web Form Submission';
$to  = 'Bram@RealEstateBram.com';
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$propdetails = $_POST['propdetails'];
$message = "
<html>
<head>
</head>
<body>
<table>
	<tr><th>Name</th><td>".$fname." ".$lname."</td></tr>
	<tr><th>Phone</th><td colspan=\"2\">".$phone."</td></tr>
	<tr><th>Email</th><td colspan=\"2\">".$email."</td></tr>
	<td colspan=\"2\">".$propdetails."</td></tr>
</table>
</body>
</html>
";
if (!mail($to, $subject, $message, $headers)) { 
	$msg = "Sending Failed.".$to." - ".$subject." - ".$message." - ".$headers;
} 
else { $msg = "Thank you"; }
echo $msg;
?>

Link to comment
Share on other sites

I get the output of

if (!mail($to, $subject, $message, $headers)) { 
	$msg = "Sending Failed.".$to." - ".$subject." - ".$message." - ".$headers;
} 

not the table right?

 

I do see the table.. this is the exact html output

Sending Failed.Bram@RealEstateBram.com - Web Form Submission - 
<html>
<head>
</head>
<body>
<table>
	<tr><th>Name</th><td>Bram Eastveld</td></tr>
	<tr><th>Phone</th><td colspan="2">416-488-2073</td></tr>
	<tr><th>Email</th><td colspan="2">MSGBram@Gmail.com</td></tr>

	<td colspan="2">I want a LOFT</td></tr>
</table>
</body>
</html>
- MIME-Version: 1.0
Content-type: text/html; charset=iso-8859-1
From: WebForm <WebForm@RealEstateBram.com>

 

 

Link to comment
Share on other sites

Add the following two lines of code after the line with your first opening <?php tag to see if there are any php detected errors as to why the mail() function call is failing -

ini_set("display_errors", "1");
error_reporting(E_ALL);

 

I added the lines you suggested so my code now reads

<?php
ini_set("display_errors", "1");
error_reporting(E_ALL);

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: WebForm <WebForm@RealEstateBram.com>' . "\r\n";
$subject = 'Web Form Submission';
$to  = 'Bram@RealEstateBram.com';
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$propdetails = $_POST['propdetails'];
$message = "
<html>
<head>
</head>
<body>
<table>
	<tr><th>Name</th><td>".$fname." ".$lname."</td></tr>
	<tr><th>Phone</th><td colspan=\"2\">".$phone."</td></tr>
	<tr><th>Email</th><td colspan=\"2\">".$email."</td></tr>
	<td colspan=\"2\">".$propdetails."</td></tr>
</table>
</body>
</html>
";
if (!mail($to, $subject, $message, $headers)) { 
	$msg = "Sending Failed.".$to." - ".$subject." - ".$message." - ".$headers;
} 
else { $msg = "Thank you"; }
echo $msg;
?>

 

The output is the same though, no additional msgs

Link to comment
Share on other sites

That either means -

 

1) The ini_set() function is disabled on your server (you cannot turn on display_errors to find what error is occurring),

2) the mail() function is disabled on your server, or

3) Your mail server has been configured to silently accept emails that it has no intention of sending so as to not provide hackers with any server information in the form of error messages.

 

In any of those cases, you would need to contact your web host to find out the requirements for sending email.

Link to comment
Share on other sites

That either means -

 

1) The ini_set() function is disabled on your server (you cannot turn on display_errors to find what error is occurring),

2) the mail() function is disabled on your server, or

3) Your mail server has been configured to silently accept emails that it has no intention of sending so as to not provide hackers with any server information in the form of error messages.

 

In any of those cases, you would need to contact your web host to find out the requirements for sending email.

 

I spoke with them today and they assured me that mail() is working... I'll call them, thank you

 

 

Link to comment
Share on other sites

Then it is likely that only your web host will be able to tell you why the mail() function call is returning a false value.

 

I'm on the phone with them now, they said that the from address is not being used... the server is complaining that one isnt being provided or something... been on the phone for 15mins... hope they can tell me what's up

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.