Avatar of Robert Granlund
Robert Granlund
Flag for United States of America asked on

PHP plain text email

I can not figure out why this plain text email will not send with PHP.  Any insight will be helpful:
<?php
$body = 'Dear Colleague,
 
If you have any questions or would like to have a brief chat, feel free to contact me.

I look forward to hearing from you.  In the mean time, best regards and have a great day.';
                       $e = "your_email@YOUREMAIL.com";
$subject = 'Website Stuff';
                        $headers = 'From: My Site <rgranlund@MYSITE.com>' . "\r\n";
                        $headers .= 'Bcc: info@MYSITE.com' . "\r\n";

                        if(mail($e, $subject, $body, $headers)) {
                            echo "mail Sent.";
                        } else {
                            echo "Mail NOT sent.";
                        }

Open in new window

PHPWeb DevelopmentEmail Protocols

Avatar of undefined
Last Comment
Robert Granlund

8/22/2022 - Mon
gr8gonzo

Does the final result say "Mail NOT sent" or are you assuming it's not sent because the recipient doesn't get it?
Robert Granlund

ASKER
Both.
ASKER CERTIFIED SOLUTION
gr8gonzo

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Robert Granlund

ASKER
Mail NOT sent Array ( [type] => 32 [message] => Module 'ionCube Loader' already loaded [file] => Unknown [line] => 0 )
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Robert Granlund

ASKER
I looks like there is something wrong with my php.ini
Dave Baldwin

When I put in my own email addresses, your code works fine.  The code is Not the problem.  I don't know why you are loading 'ionCube'??  As far as I know, to use 'ionCube', you first have to compile your PHP code with it.
gr8gonzo

My guess is that if you're not getting an error message related to mail, then you don't have mail properly configured in your system.

If you try just a basic mail() in the same file, does it work?
var_dump(mail("yourown@emailaddress.com","Test Subject","Test body"));

If not, then it's very likely you need to review your php.ini for mail configuration issues and ensure your server has a proper mailer service/daemon running.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Robert Granlund

ASKER
I had upgraded my version of php in my hosting cpanel.  It had corrupted the php.ini file and some of the services offered by my hosting company.  I deleted my php.ini and generated a new on and the issue went away.
Robert Granlund

ASKER
Thanks.