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
jopet00222
Forum Newbie
Posts: 9 Joined: Wed Nov 10, 2010 12:00 am
Post
by jopet00222 » Fri Nov 12, 2010 5:45 am
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>
Celauran
Moderator
Posts: 6427 Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada
Post
by Celauran » Fri Nov 12, 2010 7:36 am
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
Post
by recuerdeme » Fri Nov 12, 2010 9:25 am
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
Post
by jopet00222 » Sat Nov 13, 2010 12:36 am
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
Post
by cpetercarter » Sat Nov 13, 2010 2:15 am
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.