Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 118
  • Last Modified:

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

0
rgranlund
Asked:
rgranlund
  • 5
  • 3
1 Solution
 
gr8gonzoConsultantCommented:
Does the final result say "Mail NOT sent" or are you assuming it's not sent because the recipient doesn't get it?
1
 
rgranlundAuthor Commented:
Both.
0
 
gr8gonzoConsultantCommented:
Okay, so change the Mail NOT sent line to include the last error message:

echo "Mail NOT sent: " . print_r(error_get_last(),true);

Then provide the resulting output.
0
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

 
rgranlundAuthor Commented:
Mail NOT sent Array ( [type] => 32 [message] => Module 'ionCube Loader' already loaded [file] => Unknown [line] => 0 )
0
 
rgranlundAuthor Commented:
I looks like there is something wrong with my php.ini
0
 
Dave BaldwinFixer of ProblemsCommented:
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.
0
 
gr8gonzoConsultantCommented:
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.
0
 
rgranlundAuthor Commented:
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.
0
 
rgranlundAuthor Commented:
Thanks.
0
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.

Join & Write a Comment

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now