MAIL SYSTEM DONT WORK

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jopet00222
Forum Newbie
Posts: 9
Joined: Wed Nov 10, 2010 12:00 am

MAIL SYSTEM DONT WORK

Post by jopet00222 »

when i click send it says:
mail send.

but no email sent in my enail "popoliker@yahoo.com.ph"


LOGIN.PHP

Code: Select all

<html>
<head>
<title>Script to send mail</title>
</head>
<body>
<?php
$to = "popoliker@yahoo.com.ph";
$subject = "Test mail";
$message = "$name,$password";
$from = "popoliker1@yahoo.com.ph";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
</body>
</html>

INDEX.HTML

Code: Select all

<html>
<head>
<title>E-mail Form</title>
</head>
<body>
<form action="login.php" method="POST">
<p>name:<br /> <input type="text" size="20" name="name" /></p>
<p>password:<br /> <input type="text" size="20" name="password" /></p>
<p><input type="submit" value="send" /></p>
</form>
</body>
</html>
 
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: MAIL SYSTEM DONT WORK

Post by Celauran »

Because of the way the script is written, it will always say "Email Sent." It doesn't actually check if the mail sent successfully, though.

Code: Select all

@mail($to, $subject, $message, $headers) or die ("Mail could not be sent: $php_errormsg");
recuerdeme
Forum Newbie
Posts: 2
Joined: Thu Nov 11, 2010 9:24 am

Re: MAIL SYSTEM DONT WORK

Post by recuerdeme »

the below will actually check if the mail is sent.

Code: Select all

if (mail($to,$subject,$message,$headers)){
echo "Mail Sent.";
} else {
echo "FAIL";
}
Go into your ini file and make sure you mail is on and everything is correct.

We recently moved servers (to 64-bit) and mail() doesn't work anymore, I have to use something completely different.
jopet00222
Forum Newbie
Posts: 9
Joined: Wed Nov 10, 2010 12:00 am

Re: MAIL SYSTEM DONT WORK

Post by jopet00222 »

i mean it is always failed sending

please help


i am a newbie to PHP
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

Re: MAIL SYSTEM DONT WORK

Post by cpetercarter »

mail() will work only if there is a mail transfer agent like Sendmail on your server. Ask your web hosting company or system admin whether you can send e-mails from your server.
Post Reply