php 5.2 mail()

is it work?

i take a domain from another company in egypt

my code is :

$to = "**************@yahoo.com";
$subject = "test";
$txt = "check your email ......";
$headers = "From: ******@********.net" . "\r\n" .
"CC: *******@******.net";

mail($to,$subject,$txt,$headers);

echo "sent";

Open in new window


please help
AHMED SAMYownerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
What is your question exactly?

Your code seems fine - is it not working? If so then there could be something with your PHP configuration that has not been setup correctly. Mail uses settings in the php.ini file to send email.

A better option might be to use PHPMailer. Among other features it allows you to send mail over an authenticated SMTP link bypassing any localhost configuration issues.

Let us know more about what your problem is - your question as it stands is not clear.
1
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
I'm with Julian. Your question could be more clear.

I'm guessing what you mean is if you move the above code from one hosting company (machine) to another, will the code work?

If this is your question, then the answer is sometimes yes + many times no.

The only way to ensure mail code works, independent of where it's moved, is to use a relay service.

MailGun is the cheapest. First 10K messages free each month. Be sure to put in a credit card to enable all features, then go through their DNS record setup completely, till you get a 100% verification from their DNS verification tool.
0
AHMED SAMYownerAuthor Commented:
i didn't work
0
AHMED SAMYownerAuthor Commented:
nothing recieved
0
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Ahmed, the posts...

i didn't work

nothing received

Convey now meaning without context.

My suggestion is you use swaks to test your connection + make sure your actual sending mechanism, whatever you're using, works correctly first.

Then convert your swaks command to PHP.

I always start with swaks first. This saves a massive amount of time.

If a swaks command fails, post the entire command + errors produced.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

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.