?
Solved

PHP plain text email

Posted on 2016-07-30
9
Medium Priority
?
93 Views
Last Modified: 2016-07-30
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
Comment
Question by:rgranlund
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 35

Expert Comment

by:gr8gonzo
ID: 41736017
Does the final result say "Mail NOT sent" or are you assuming it's not sent because the recipient doesn't get it?
1
 
LVL 7

Author Comment

by:rgranlund
ID: 41736020
Both.
0
 
LVL 35

Accepted Solution

by:
gr8gonzo earned 2000 total points
ID: 41736022
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
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
LVL 7

Author Comment

by:rgranlund
ID: 41736026
Mail NOT sent Array ( [type] => 32 [message] => Module 'ionCube Loader' already loaded [file] => Unknown [line] => 0 )
0
 
LVL 7

Author Comment

by:rgranlund
ID: 41736028
I looks like there is something wrong with my php.ini
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 41736029
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
 
LVL 35

Expert Comment

by:gr8gonzo
ID: 41736031
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
 
LVL 7

Author Comment

by:rgranlund
ID: 41736033
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
 
LVL 7

Author Closing Comment

by:rgranlund
ID: 41736034
Thanks.
0

Featured Post

WordPress Tutorial 2: Terminology

An important part of learning any new piece of software is understanding the terminology it uses. Thankfully WordPress uses fairly simple names for everything that make it easy to start using the software.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question