#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    204
    Rep Power
    3

    PHP Mail shows HTML code in some browsers


    Hi! My Html mail is showing correctly. But someone wrote me that he sees all the code en inline css.

    these are my headers

    PHP Code:
           $subject "Bedankt voor uw inschrijving";
        
    $headers "From: Jelle@sportcareers.be\r\n";
        
    $headers .= "Reply-To: Jelle@sportcareers.be\r\n";
        
    $headers .= "X-Mailer: PHP/".phpversion()."\r\n";
        
    $headers .= "MIME-Version: 1.0\r\n";
        
    $headers .= "Content-Type: text/html; charset=utf-8 \r\n"
    Does anyone know what i might be doing wrong?
    Last edited by notflip; February 11th, 2013 at 03:51 AM.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,600
    Rep Power
    595
    If it is only 1 person while the others see it fine then it is unlikely your code. More likely is that the user has HTML turned off in their reader.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    204
    Rep Power
    3
    Originally Posted by gw1500se
    If it is only 1 person while the others see it fine then it is unlikely your code. More likely is that the user has HTML turned off in their reader.
    It's 2 persons out of 65 haha.. Is there a possibility to check for HTML enabled or not ? and if not just output plain text without HTML & CSS. thanks!
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,600
    Rep Power
    595
    No since that is a client setting. The only thing you can do is create a multi-part email. You essentially create the message in two parts. One is in plain text for those have have HTML off or use a reader that cannot display HTML and the other is with the HTML you use now. You can also send just plain text which all readers can handle.

    Comments on this post

    • ManiacDan agrees
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  8. #5
  9. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Hi,

    in case you do want to send a multipart mail (which makes a lot of sense), I strongly suggest using a mailer library like phpmailer or Swift Mailer.

    I'm surprised that so many people still fumble with lowlevel stuff like mail headers and boundary strings when there are more than enough libraries to take care of that.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  10. #6
  11. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Location
    The Pleiades
    Posts
    300
    Rep Power
    9
    I like using mail and sending emails 'manually' but I must say libraries are very very useful, especially when you are not sure on a certain function or how to code it properly.

    I now use PHPass to hash all my passwords before sending them to a database. I was sick and tired of attempting to create a secure password hash, and after a few weeks of trying, I went onto a forum and was told about using PHPass to hash your user passwords. Because it is so easy to install and use, I will be using PHPass all the time now in whatever project.

    Kind regards,

    NM.

IMN logo majestic logo threadwatch logo seochat tools logo