PDA

View Full Version : [php]mail() function is not working...


3pepe3
02-28-2008, 08:37 PM
Hello world...

I'm very stucked...
I was using a php and flash form to send mails...I was having no problems.
Now I'm trying to use the same and nothing seems to work.
just for test porpouse i'm using this php from this thread (http://www.actionscript.org/forums/showthread.php3?t=131264&page=2)


<?php
echo "sending mail<br>";
$recipients = "prueba_brutal@yahoo.com.mx";
$subject = "Contact Form Message";

$name = "pepe";
$email = "pepe.design@hotmail.com";
$phone = "48-456-789";
$message = "hello world";
$address = "gab kl 256";

$date = date("F j, Y", time());

$email_info .= "Below is the visitors contact info and message.\n\n";
$email_info .= "Visitor's Info:\n";
$email_info .= "-----------------------------------------\n";
$email_info .= "Name: " . $name . "\n";
$email_info .= "Phone: " .$phone . "\n";
$email_info .= "Address: " .$address . "\n";
$email_info .= "Email: " . $email . "\n";
$email_info .= "Date Sent: " . $date . "\n\n";
$email_info .= "Message\n";
$email_info .= "-----------------------------------------\n";
$email_info .= "" . $message . "\n";

$mailheaders .= "From: $name <$email>\n";
$mailheaders .= "Reply-To: " . $email . "\n\n";
echo $recipients."<br>";
echo $subject."<br>";
echo $email_info."<br>";
echo $mailheaders."<br>";

$ok = mail($recipients, $subject, $email_info, $mailheaders); //this line sends the mail and returns true or false
if($ok) {
echo "server_mes=ok";
} else {
echo "server_mes=fail";
}


?>


Also when i check for the $ok it returns true... but not mail received....
What's wrong????
here is the link for test: http://www.pepemagana.com/others/mail.php This is killing me!!!!

Thanks.
Pepe Magaņa

CyanBlue
02-28-2008, 08:45 PM
So, your problem is that the mail is never sent???

Create a new PHP file with this and run it over the web browser to see if you get the email...
<?php
mail("your@email", "test email", "blah blah");
?>

3pepe3
02-28-2008, 08:51 PM
:(
Thanks CyanBlue.... no luck.... test link (http://www.pepemagana.com/others/mail1.php) but the mail is not sent.
:s

CyanBlue
02-28-2008, 08:57 PM
Time to have a chat with the hosting company then... They have some special setting you need to add inside the PHP or some other way to activate the mail() function... :(

3pepe3
02-28-2008, 09:20 PM
mmmmmmmmmmmhhhh... looks like in my new server this is the only function that it's having the problem.
I discover this problem because i was testing on godaddy's hosting an e-mail form... but looks like also i'm having problems writting some files with fwrite()
:mad:
well i will contact the companies (and will be posting the solution)...
thanks cyanblue
:)

3pepe3
03-01-2008, 10:54 AM
Thanks CyanBlue...
I contacted my web hosting (ixwebhosting)...

And i just need to add one line to the code... now it works.

<?php
ini_set('sendmail_from', 'webmaster@myDomain.com');
$ok=mail("sample@yahoo.com", "test email", "blah blah");
echo $ok;
?>

ASWC
03-01-2008, 12:41 PM
I had the same poblem with my host. I thought it wasn't working but in fact it was, only I was recieving the emails a few days later???? Now with the init_set I recieve them within one hour or so. Still far from what I want! :mad:

CyanBlue
03-03-2008, 01:46 PM
Ah, yeah... I remember that liner... Glad to hear that it solved the problem, 3pepe3... ;)

ASWC... A few days later??? Did you somehow forget to put the stamp??? :p
That still is weird though... Maybe the host has a setup that runs mailing process hourly or something??? Hm...