Jump to content

php mail function


kney

Recommended Posts

Why doesn't this send the mail?

 

if (isset($_POST['sendMail'])){
        $to = "kenneth.dehouwer@devoteam.be";
$subject = "TEST email";

$message = "
<html>
<head>
<title>HTML email</title>
</head>
<body>
<p>This email contains HTML Tags!</p>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</table>
</body>
</html>
";

// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

// More headers
$headers .= 'From: <webmaster@felnet.be>' . "\r\n";
$headers .= 'Cc: myboss@example.com' . "\r\n";

mail($to,$subject,$message,$headers);
}

Link to comment
Share on other sites

@WebStyles: The code above is the one I have now.

@PFMaBiSmAd: None of the code ever worked.

@AyKay47: Where can I configure the error logging?

 

 

 

add theses lines to the top of your script, this will print any errors you are receving directly onto your webpage

 

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

Link to comment
Share on other sites

I checked my spam folders, nothing's there.

I also tried with 3 different email addresses and checked them if they were correct.

 

The php.ini file has this configured:

SMTP = localhost
smtp_port = 25
mail.add_x_header = On
mail.log = C:\

Link to comment
Share on other sites

Are you sure your $_POST['sendMail'] variable is set to that your code is even calling the mail() function?

 

At a minimum, you should have error checking logic in your code to test the value mail() returns and display a success or failure message so that you know the result of calling the mail function.

Link to comment
Share on other sites

This is the error i'm getting..

 

Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in \web\RecordDrivers\IndexRecord.php on line 322 Notice: Use of undefined constant mail - assumed 'mail' in \web\RecordDrivers\IndexRecord.php on line 323

Link to comment
Share on other sites

seems like you do not have an SMTP server set up on your localhost, in my opinion, i never encourage tampering with sending mail until your webpage is on a live server.. the host will provide the mail server for you.. however there are also third party mail servers out there

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.