so i tried this first. every thing works and get a message echo"message successfully, sent".
but when i check my email nothing comes.

    //$email is the user email
                $to = $email;
                    $subject = "Forgot password";
                    $message = "Hi $firstname_db,\n Your password is $password_db";
                    $headers = "from: text@hotmail.com";

                    if(mail($to, $subject, $message, $headers))  //lline 49
                    {
                    echo "message successfully sent";
                    } 
                    else
                    { 
                        echo "failed";
                    }

so i tried different method but still no luck.

                    $to = $email;
                    $subject = "Forgot password";
                    $message = "Hi $firstname_db,\n Your password is $password_db";
                    $header = "From: text@hotmail.com";

                     function mail_utf8($to, $subject = '(No subject)', $message = '', $header = '') { 
                $header_ = 'MIME-Version: 1.0' . "\r\n" .
                 'Content-type: text/plain; charset=UTF-8' .   "\r\n" .
                 'Content-Transfer-Encoding: base64' . "\r\n"; 
      mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', base64_encode($message), $header_ . $header);  
 }

Recommended Answers

All 2 Replies

In the many years I've been developing with php, mailing is always a big pain point I see. As much as I like to advocate learning how to implement something yourself to have a better understanding of how things work and then looking for a more rigorously tested solution or building one, this is one of the few situations I'd say skip learning how to implement a mailing solution well. The specs are vast and complicated and if you're just trying to send emails it is easier to use a 3rd party library that will simplify all of it. If you simply rely on php's mail() function you will have nothing but headaches dealing with bounces and spam hits.

I really like the SwiftMailer (http://swiftmailer.org/) library. It is a great library with robust functionality that has seen a lot of recent attention thanks to the Symfony2 framework.

Zend_Mail is also a great package (http://framework.zend.com/manual/en/zend.mail.html) however I'm not sure how easy/difficult it would be to use it standalone. I'm sure there are tutorials that would explain what is necessary.

PHP Mailer is also one of the other big players. (http://phpmailer.worxware.com/)

iam using phpmailler.
so i just put top of my file require_once('class.phpmailer.php');

there is only one file called class.phpmailler i put in my folder?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.