0

I am using the php mail() function, but it doesn't work when i set the header content-type to text/html.

So this works:

mail('to@mail.com','test','test',
'From: from@mail.com
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit');

But when i change text/plain to text html, so like this:

mail('to@mail.com','test','test',
'From: from@mail.com
MIME-Version: 1.0
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: 8bit');

It doesnt work anymore. I don't get any error messages, but mail() first returns true, and after changing the content type it returns false.

Edit to clarify duplicate status

The linked question contains a global question, and the answers are not even close to give an answer for this situation. I am trying to debug this problem, suggesting something like: Just use a library is not a valid response for this.

user4493177
  • 750
  • 11
  • 32
  • @mario Just because an answer contains some helpfull information in general, does not make it a duplicate. I also don't include everything i did in here, i tried to put the relevant info only. The main part of debugging resulted in locating the exact problem. If you need more specific information, you can ask instead of downvote. This simply is no duplicate, if you think i didn't do enough research before posting, you have the flag option for that. Right now you are calling duplicate incorrectly and simply abusing your status. – user4493177 Jul 04 '16 at 02:13
  • Nobody is entitled to be begged for details, nor for yet another list of guess-the-problem. Your prior research is what you may or may not present here. And that's very precisely what voting is for. This question pretty clearly does not go much beyond "something doesn't work" and is unlikely to help future vistiors any more than the hundreds of similar questions that preceded it. – mario Jul 04 '16 at 02:40
  • @mario If there are hundreds of similar questions, then i really wonder why you couldn't pick one of those for duplicate. Fact remains that the question you linked is not the same as this one, nor are the answer sufficient to solve this problem. Also, if everyone has perfect knowledge of every subject, this site would not exist. It is very normal that when dealing with a problem, someone does not know exactly what the relevant details are for solving. As i said, my research was locating the exact error, here the content type. – user4493177 Jul 04 '16 at 11:33
  • Not my job to wade through https://www.google.de/search?q=site:stackoverflow.com+php+mail+doesn't+send+text/html for ya, or guess your server setup. Yes that's the hint. The code is largely irrelevant. – mario Jul 04 '16 at 12:07
  • It's easy to deduplicate your question if you elaborated on **each** of the points raised in the reference answer. Just saying "No! No! No! It's not the same issue!!1!" is insufficient. – mario Jul 04 '16 at 12:12
  • @mario If you would look at the most accepted answer there, you see it is more a basic debugging guide than a specific answer. When an answer consist of things like: Turn on your debugging, check if you call your mail() function (really?), use a library etc, that might be very usefull, but it does not mean that you can copy paste that answer to every question about the same subject. – user4493177 Jul 04 '16 at 19:52

0 Answers0