how can i test mail() on my server to know it is working

how can i test mail() on my server to know it is working

i have hosting i sent message from mail :

$to = "$co_email";
$subject = "*****";
$txt = "set your password by this link :  http://********/setpassword.php";
$headers = "From: admin@*******" . "\r\n" . 
"CC: ************";

Open in new window

from my hosting done

another hosting failed

the same php 5.6
AHMED SAMYownerAsked:
Who is Participating?
You need to know if the server in question is allowed to send out emails, and if not, have the hosting company provide you with the correct info (other SMTP server)
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Use the mail command on the command line or use sendmail directly, as most MTAs provide a sendmail wrapper.

Here's the thing though. Just because you can send email does not mean it will every be accepted or delivered.

Email sending + accepting (by external host) + delivery (on external host) are all three distinct operations.

If you've implemented all steps in my comments here, then you understand what's required to manage a native MTA. Keep in mind, you'll have to repeat these steps for each machine you use + each time you change hosting.

And you'll likely requires a few hours/day managing your return loop.

Or you can use a service like MailGun + you'll be setup in a few minutes with 100% deliverability + your code will work forever, independent of your runtime environment (hosting).
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.