1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Whats wrong in this email script

Discussion in 'PHP' started by greatlogix, Feb 12, 2008.

  1. #1
    function send_mail($myname, $myemail, $contactname, $contactemail,$subject, $message){
    $headers ="";
    $headers .= "MIME-Version: 1.0\n";
    $headers .= "Content-type: text/html;\n\tcharset=\"iso-8859-1\"\n";
    $headers .= "X-Priority: 3\n";
    $headers .= "X-MSMail-Priority: Normal\n";
    $headers .= "X-Mailer: MyMailer\n";
    $headers .= "To: \"$contactname\" <$contactemail>\n";
    $headers .= "From: \"$myname\" <$myemail>\n";
    $headers .= "Reply-To: \"$myname\" <$myemail>\n";
    return( mail( $contactemail, $subject, urldecode($message), $headers ) );
    }
    PHP:
    I am using this simple email functions from years without any errors. From last month I am receiving complaints from customers that their order receipts are junk html code ("<td>order no 15"</td>"....) and they can't view order receipts. I did not notice any problem as I am getting copy of order receipts at yahoo without any error (HTML formatted). Please comment how to fix it?
     
    greatlogix, Feb 12, 2008 IP
  2. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Try replacing your "\n" line endings with "\r\n" to make them compatible with most, if not all, mail servers.

    Jay
     
    jayshah, Feb 12, 2008 IP
    greatlogix likes this.
  3. DarkMindZ

    DarkMindZ Guest

    Messages:
    175
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3

    Use those headers instead, I use them and never had any problem :)
     
    DarkMindZ, Feb 12, 2008 IP
    greatlogix and mab like this.
  4. greatlogix

    greatlogix Active Member

    Messages:
    664
    Likes Received:
    13
    Best Answers:
    1
    Trophy Points:
    85
    #4
    One customer replied that problem is in outlook. Online web based emails are perfect. Thanks DarkMindZ and Jay. I will try both of your suggestions. Rep added.
     
    greatlogix, Feb 12, 2008 IP
  5. mab

    mab Active Member

    Messages:
    563
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    80
    #5
    i don't know how to thank you DarkMindZ for your code ! REP++
     
    mab, Feb 13, 2008 IP
  6. mab

    mab Active Member

    Messages:
    563
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    80
    #6
    hmm now it does not work anymore .. it comes to the junk :(
     
    mab, Feb 14, 2008 IP
  7. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #7
    That doesn't mean it doesn't work. That means you are probably sending spam (or something that is being perceived as unsolicited commercial email) :)
     
    jayshah, Feb 14, 2008 IP
  8. mab

    mab Active Member

    Messages:
    563
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    80
    #8
    Well i'm sending it to me with hello title .. i'm not doing a spam !
     
    mab, Mar 3, 2008 IP
  9. DarkMindZ

    DarkMindZ Guest

    Messages:
    175
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Show me the full script please.

    plus, did you change the server that you are sending from? or any mail settings? that can affect it too.
     
    DarkMindZ, Mar 3, 2008 IP
  10. chanakya

    chanakya Peon

    Messages:
    361
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Check with your customer he/she may have enabled text view in outlook, HTML will not show up if this is the case
     
    chanakya, Mar 3, 2008 IP
  11. chanakya

    chanakya Peon

    Messages:
    361
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Check with your customer he/she may have enabled text view in outlook, HTML will not show up if this is the case
     
    chanakya, Mar 3, 2008 IP
  12. juust

    juust Peon

    Messages:
    214
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #12
    the problem is the urldecode function that breaks the html-markup stored in the
    $message variable

    it could be a worm, get your machine checked just to be sure.

    if you use a yy/mm/dd style date in the message it is 'escaped' as
    yy%eemm%eedd.

    in the final 'mail' command you use urldecode and the sequence is
    interpreted incorrectly into some other sign, maybe ' or " and then
    you get open strings in the html-source and the thing is dumped as
    raw text.
     
    juust, Mar 3, 2008 IP
    greatlogix likes this.