E-mail FROM getting messed up

Discussion in 'PHP' started by DoubleDee, Sep 15, 2012.

  1. #1
    My website is set up to e-mail me - as the Admin - when there is an error on a webpage.

    In my Gmail, I am getting this in the FROM column...

    ...which is obviously syntactically messed up?!


    Here is the code I have in my script which sends the e-mail...

    
    $headers  = "From: admin@MySite.com <admin@MySite.com>\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
    
    mail('Debbie@gmail.com', 'Re: Website #: ' . rand(5, 1000), $body, $headers);
    
    PHP:

    The only thing I can think of is that my Single Quotes are messing something up?!

    (BTW, I am getting the e-mail, and it is readable, but I just want the format of the FROM to be correct...)

    Thanks,


    Debbie
     
    DoubleDee, Sep 15, 2012 IP
  2. nabil_kadimi

    nabil_kadimi Well-Known Member

    Messages:
    1,065
    Likes Received:
    69
    Best Answers:
    0
    Trophy Points:
    195
    #2
    Replace this
    $headers  = "From: admin@MySite.com <admin@MySite.com>\r\n";
    PHP:
    With this:
    $headers  = "From: Admin <admin@MySite.com>\r\n";
    PHP:
    Or this:
    $headers  = "From: admin@MySite.com\r\n";
    PHP:
    I assume the From headers should have the same format as the recipient
    http://php.net/manual/en/function.mail.php#refsect1-function.mail-parameters:
     
    nabil_kadimi, Sep 16, 2012 IP
  3. zubizubi

    zubizubi Active Member

    Messages:
    946
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    83
    #3
    Cant help you with this!
     
    zubizubi, Sep 16, 2012 IP
  4. DoubleDee

    DoubleDee Greenhorn

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #4
    I'll keep an eye on things when I have errors and see if that change helped.

    Thanks!


    Debbie
     
    DoubleDee, Sep 16, 2012 IP