mail function using

how to use mail function and explain with code

Page 1 of 1

4 Replies - 906 Views - Last Post: 08 July 2009 - 10:40 PM Rate Topic: -----

#1 nagarajan22  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 28-June 09

mail function using

Post icon  Posted 07 July 2009 - 02:12 AM

<html>
<body>

<?php
if (isset($_REQUEST['email']))
  {
  $email = $_REQUEST['email'];
  $subject = $_REQUEST['subject'];
  $message = $_REQUEST['message'];
  mail( "nagarajan22@gmail.com", "Subject: $subject",
  $message, "From: $email" );
  echo "Thank you for using our mail form";
  }
else
  {
  echo "<form method='post' action='new.php'>
  Email: <input name='email' type='text' /><br />
  Subject: <input name='subject' type='text' /><br />
  Message:<br />
  <textarea name='message' rows='15' cols='40'>
  </textarea><br />
  <input type='submit' />
  </form>";
  }
?>

</body>
</html>  

and another one is
<?php
$to = "nagarajan22@gmail.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "y2n_007in@yahoo.com";
$headers = "From: $from";
mail($to, $subject, $message, $headers);
echo "Mail Sent.";
?> 



i wrote this script refer with internet, but it is not working.....
pls anyone help me...

Is This A Good Question/Topic? 0
  • +

Replies To: mail function using

#2 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5304
  • View blog
  • Posts: 27,195
  • Joined: 10-May 07

Re: mail function using

Posted 07 July 2009 - 02:20 AM

View Postnagarajan22, on 7 Jul, 2009 - 03:12 AM, said:

i wrote this script refer with internet, but it is not working.....

Can you describe "is not working"?

What isn't working... exactly?
Was This Post Helpful? 0
  • +
  • -

#3 Jono20201  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 179
  • Joined: 07-July 09

Re: mail function using

Posted 07 July 2009 - 12:43 PM

If it doesn't error but you don't get the email,
try a bit of debugging (as i like to call it)

try:
<?php
$to = "nagarajan22@gmail.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "y2n_007in@yahoo.com";
$headers = "From: $from";
$send = mail($to, $subject, $message, $headers);
if(!$send){
echo "error";
} else {
echo "Mail Sent.";
}
?>



Now run this script and if it still says "Mail Sent." then i have no idea.
If it says "error" then you may not have you php.ini setting right or something.
Was This Post Helpful? 0
  • +
  • -

#4 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5304
  • View blog
  • Posts: 27,195
  • Joined: 10-May 07

Re: mail function using

Posted 08 July 2009 - 06:40 PM

View PostJono20201, on 7 Jul, 2009 - 01:43 PM, said:

...if it still says "Mail Sent." then i have no idea.

You won't get an error because PHP doesn't have built-in SMTP error handling. The mail function sends the email, & doesn't care what happens to it. It's possible that your problem lies beyond the scope of PHP.

Is this server a mail server?
Is port 25 open?
Are the mail headers malformed?
Did the receiving email address/isp consider it or you spam?
Was This Post Helpful? 0
  • +
  • -

#5 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1641
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: mail function using

Posted 08 July 2009 - 10:40 PM

Are you receiving any errors? Does this code not work that way you intended it? When asking for help there are a couple items that are vital in order for someone to properly help you:
  • Post the code you're having problems with
  • Post the exact error you're receiving, if you are receiving one
  • If no error explain what the code is doing versus what you want it to do
  • Post your question in the body of your post, not the description field

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1