Problem with mail function

Hi,

I got a problem with my site.
So i got a form on a html website.
i try to mail the information on the form to my email but i never receive an email.
Can someone look at my code to see whats wrong?

<?php

$name = $_REQUEST['name'] ;

$message = "
<html>
<head>
  <title>Info</title>
</head>
<body>
<h1>Info</h1>
Name: $name <br>
</body>
</html>
";

$to = 'me';
$subject= "stuff";

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: someone';

$success = mail($to, $subject, $message, $headers);

if ($success) 
{
  header( "Location:success page" );
}
else {
  header( "Location:failure page" );
}

?>

I’m able to echo my message correctly… but i always get redirected to the failure page… it’s probably something stupid… but can’t find it.

Any help would be appreciated!

you are putting actual email addresses in these two spots right?
$to = ‘me’;
$headers .= ‘From: someone’;

also in the from spot try using an email address that you created at your hosting company server. Some host companies won’t allow you to send emails with fake addresses

Hi,

plintu is right; you’ve got to specify a valid recipient for your email…

By the way, you can also use geekmail – it’s a stand-alone library that simplifies sending of email using PHP. You can even attach files. Just download the library here: http://goo.gl/bYUPL.

Here’s how the implementation looks like:

[php]require ‘geekMail-1.0.php’;

$geekMail = new geekMail();

$geekMail->setMailType(‘html’);

$geekMail->from(‘[email protected]’, ‘Your Name’);

$geekMail->to(‘[email protected]’);
//$geekMail->cc(‘[email protected]’);
//$geekMail->bcc(‘[email protected]’);

$geekMail->subject(‘Sample Subject’);

$geekMail->message(‘This is an example message.’);

$geekMail->attach(’/images/file.zip’);
$geekMail->attach(’/images/file2.zip’);

if (!$geekMail->send())
{
$errors = $geekMail->getDebugger();
print_r($errors);
}[/php]

:slight_smile:

thx for the replies.

in my real code i did put an email adres there.

But i found out what the problem was. apparently i’ve send to much mails because they all got through.
My host was bloking my outgoing mails because for testing i was sending to much mails :).

Thanks anyway

Sponsor our Newsletter | Privacy Policy | Terms of Service