Whats wrong with this email script?

Discussion in 'PHP' started by greatlogix, Jan 20, 2009.

  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 script to send emails. Some customers are not getting emails in pure html format. They are getting junk like this.

    Return-Path: <xxxxx@xxxx.host.com>
    Received: from xxxxxx.cox.net ([70.169.32.70])
            by fed1rmmtai111.cox.net
            (InterMail vM.7.08.02.01 201-2186-121-102-20070209) with ESMTP
            id
    <20090120103219.CCUA17776.xxxxxxxx.cox.net@fed1rmimpi03.cox.net>
            for <r-mhegadore@cox.net>; Tue, 20 Jan 2009 05:32:19 -0500
    Received: from outbound-mail-140.host.com ([67.222.39.30])
          by xxxxxxx.cox.net with IMP
          id 5mYH1b00Z0f2Fuj05mYJ1g; Tue, 20 Jan 2009 05:32:18 -0500
    Received: (qmail 30279 invoked by uid 0); 20 Jan 2009 10:32:20 -0000
    Received: from unknown (HELO xxxx.host.com) (69.89.22.131)
     by outboundproxy4.host.com with SMTP; 20 Jan 2009 10:32:20 -0000
    Received: from localhost ([127.0.0.1] helo=xxxx.host.com)
          by xxxx.host.com with esmtp (Exim 4.69)
          (envelope-from <xxxx@xxxx.xxxx.com>)
          id 1LPDu8-0003Cj-3w; Tue, 20 Jan 2009 03:32:20 -0700
    X-VR-Score: -100.00
    X-Authority-Analysis: v=1.0 c=1 a=nAlSeYmHZaIA:10
    a=oJIBp+euDYWN1Lx251TX2A==:17 a=OlGl0nCSAAAA:8 a=7zz7k8U4KiDxvD15Ey4A:9
    a=V5JoWqldoTifYARHM6kA:7 a=_ndnGEjAyurlnXpdtGPPUShev00A:4 a=tfoDBM7hCYoA:10
    a=GeK_bFF7fJUA:10 a=uOaRpS669cgA:10 a=4vB-4DCPJfMA:10 a=BMUHMS3u0ToA:10
    X-CM-Score: 0.00
    DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default;
    d=company.com;
    
    h=Received:Date:To:Subject:MIME-Version:Content-type:X-Priority:X-MS
    Mail-Priority:X-Mailer:To:From:Reply-To:X-Identified-User;
    
    b=NE4AWwl6+5IY/hBP5Yo8SG8qPw8uqA0FSylsNQ6KQ5NMIXNPgOUownEIWjbt9VdWjC
    4OAEx6m6txeGlPKHjKmCAzirf0O2RM4ZzqdZ0ojzF8mNL0y8YTy0OR4ML68Iqh;
    Date: Tue, 20 Jan 2009 05:32:20 -0500
    To: xxxxxx@cox.net
    To: " " <xxxxx@cox.net>
    Subject: Order Received!
    MIME-Version: 1.0
    Content-type: text/html;
          charset="iso-8859-1"
    X-Priority: 3
    X-MSMail-Priority: Normal
    X-Mailer: MyMailer
    From:  "Company" <sales@Company.com>
    Reply-To: "Company" <sales@Company.com>
    X-Identified-User: {1248:box131.hosting.com:Company:Company.com}
    {sentby:program running on server}
    Message-Id:
    <20090120103219.CCUA17776.xxxxxxxxxx.cox.net@xxxxx.cox.net>
    
    
    <table width='100%' border='0' cellspacing='0' cellpadding='0'>
                    <tr><td>
                    <table width='100%' border='0' >.............. and so on
    Code (markup):
    Is there any problem with email headers or something else i have to do to fix this issue?
     
    greatlogix, Jan 20, 2009 IP
  2. osmasters

    osmasters Well-Known Member

    Messages:
    453
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    100
    #2
    Just try with below functions and if it's working fine then your code may have some problem otherwise your mail server has some problem.

    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 .= "To: \"$contactname\" <$contactemail>\n";
    return( mail( $contactemail, $subject, urldecode($message), $headers ) );
    }


    //////////////////OR/////////////////

    function send_mail($myname, $myemail, $contactname, $contactemail,$subject, $message){
    return( mail( $contactemail, $subject, urldecode($message), $headers ) );
    }
     
    osmasters, Jan 20, 2009 IP
  3. greatlogix

    greatlogix Active Member

    Messages:
    664
    Likes Received:
    13
    Best Answers:
    1
    Trophy Points:
    85
    #3
    I have already tried above. Same problem. Are you sure problem is at mail server
     
    greatlogix, Jan 21, 2009 IP
  4. jonhel

    jonhel Peon

    Messages:
    26
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I was experiencing problems such as this when I first moved away from using the PHP mail() command to send html messages etc.

    I eventually moved to using the PHP Mailer class that I downloaded and installed which has made the process of sending emails with my scripts much easier.

    I know this doesn't answer the query but you might find a similar solution helpful?

    Jonathan
     
    jonhel, Jan 21, 2009 IP
  5. t3nt3tion

    t3nt3tion Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I`d recommend using phpmailer, as it`s free and has alot of already made functions easy to use.
     
    t3nt3tion, Jan 22, 2009 IP
  6. mrmaf

    mrmaf Peon

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    mrmaf, Jan 23, 2009 IP