By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,890 Members | 1,050 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,890 IT Pros & Developers. It's quick & easy.

Problem sending mail using PHP's mail() function.

P: 11
I'm using Ubuntu OS,

I'm trying to send a mail through a program, but I'm not able to do this.

This is the program,

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. $Name = "xxx"; 
  4. $email = "xxx@xxx.com"; 
  5. $recipient = "xxx@xxx.com"; 
  6. $mail_body = "The text for the mail..."; 
  7. $subject = "Testing mail"; 
  8. $header = "From: ". $Name . " <" . $email . ">\r\n"; 
  9.  
  10. if
  11. (mail($recipient, $subject, $mail_body, $header))
  12.     {
  13.       echo("Message sent");
  14.     }
  15.     else{
  16.          echo("Not sent");
  17.        }
  18. ?>
  19.  
Plz... help me to come out of this prob.
Sep 12 '08 #1
Share this Question
Share on Google+
4 Replies


100+
P: 107
how about some more info..

like what if any error messages you get?

throw us a bone here!
Sep 12 '08 #2

P: 11
It will just display on browser that "Not sent".
Sep 13 '08 #3

Atli
Expert 5K+
P: 5,058
Hi.

Try to turn on the error messages and see what that tells you.

There is essentially nothing wrong with that code. The problem is with your OS. For the mail() function to work, PHP must be configured correctly, the [mail] section has to be set to valid values.

I recommend avoiding the mail function. There are better methods available, such as the PHPMailer class, or the Swift Mailer class.

I would recommend trying them first.
Sep 13 '08 #4

P: 11
I have turned on the error messages, but it is not showing any error, and even not sending the mail.
Even now it's displaying "not sent".

Yes! I will try PHPMailer, and swiftmailer.

But I want this "mail()" should work.


Thanx...


Hi.

Try to turn on the error messages and see what that tells you.

There is essentially nothing wrong with that code. The problem is with your OS. For the mail() function to work, PHP must be configured correctly, the [mail] section has to be set to valid values.

I recommend avoiding the mail function. There are better methods available, such as the PHPMailer class, or the Swift Mailer class.

I would recommend trying them first.
Sep 17 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.