MIME type in Mail.php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • maheswaran
    New Member
    • Mar 2007
    • 190

    MIME type in Mail.php

    Hi ,

    Am new in PEAR. I have using PEAR/Mail.php for sending mails using smtp authentication. Here that my mailto form.
    [php]<?php
    session_start() ;
    ini_set("smtp_p ort",25);
    include("Mail.p hp");
    $name=$_POST["name"];
    $email=$_POST["email"];
    $phone=$_POST["phone"];
    $company=$_POST["company"];
    $message=$_POST["message"];
    if( isset($_POST['security_code'])) {
    if( $_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSIO N['security_code'] ) ) {
    // Insert you code for processing the form here, e.g emailing the submission, entering it into a database.
    //echo 'Thank you. Your message said "'.$_POST['message'].'"';
    //Generate Mail
    //=============== =
    // To send HTML mail, you can set the Content-type header.
    $headers = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    $headers .= "From: xxxxxx";
    $recipient="xxx xxxxx";
    //subject
    //========
    $subject="Send Mail.";
    //message
    //=======
    $message="
    <table width=60% border=0 cellpadding=4 cellspacing=1 bgcolor=#cccccc >
    <TR>
    <TD colspan=2><font face=Arial size=2><b>Send Mail </b></font></td>
    </tr>
    <TR>
    <TD bgcolor='#EFEFE F'><font face='Arial' size='2'>Name</font></td>
    <TD bgcolor='#FFFFF F'><font face=Arial size=2>$name</font></td>
    </tr>
    <tr>
    <td bgcolor='#EFEFE F'><font face='Arial' size='2'>Email ID</font></td>
    <td bgcolor='#FFFFF F'><font face=Arial size=2>$email</font></td>
    </tr>
    <tr>
    <td bgcolor='#EFEFE F'><font face='Arial' size='2'>Teleph one</font></td>
    <td bgcolor='#FFFFF F'><font face=Arial size=2>$phone</font></td>
    </tr>
    <tr>
    <td bgcolor='#EFEFE F'><font face='Arial' size='2'>Compan y</font></td>
    <td bgcolor='#FFFFF F'><font face=Arial size=2>$company </font></td>
    </tr>
    <tr>
    <td bgcolor='#EFEFE F'><font face='Arial' size='2'>Commen ts / Messages</font></td>
    <td bgcolor='#FFFFF F'><font face=Arial size=2>$message </font></td>
    </tr>
    </table>";
    //SMTP process start========== ===========
    $body=$message;
    $smtp_obj=new Mail;
    $from="xxxx@xx. x";
    $host = "xxxx";
    $username = "xxxx@xx.xx ";
    $password = "xxxx";
    $to="xxx@xx.xx" ;
    // $subject= mb_encode_mimeh eader($subject, "UTF-8", "B", "\n");
    $headers = array ('From' => $from,
    'To' => $to,
    'Subject' => $subject);
    $smtp = Mail::factory(' smtp',
    array ('host' => $host,
    'auth' => true,
    'username' => $username,
    'password' => $password));
    $mail = $smtp_obj->send($to, $headers, $body);
    if (!PEAR::isError ($mail))
    //echo("<p> Sorry, you have provided an invalid security code</p>");
    $content= 'Our Representative will contact you soon. Thank you for contacting us.';
    unset($_SESSION['security_code']);
    } else {
    //echo("<p>Messag e successfully sent!</p>");
    $content= 'Sorry, you have provided an invalid security code<br><br>';
    $content.= '<input type="button" value="Go back" onClick="histor y.back();">';
    }
    }
    ?>[/php]And am inlcude pear/mail.php

    Using this i got mail...But html tags printed with our parsing..i think it print text mime type... How can i change into html
    Last edited by ronverdonk; May 26 '08, 02:31 PM. Reason: warning: use code tags!
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    LAST WARNING:
    As a member you (should) know by now, and you have been warned before, that you have to include any code within the appropriate code tags! Please enclose your posted code in [code] tags (See How to Ask a Question).

    This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

    Use [code] tags in future.

    MODERATOR

    Comment

    • maheswaran
      New Member
      • Mar 2007
      • 190

      #3
      I got the answer for above one


      Just modify the below code

      <php code>
      $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject);
      <php code>
      into


      $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject,'Heade rs'=>$headers);

      Comment

      • hsriat
        Recognized Expert Top Contributor
        • Jan 2008
        • 1653

        #4
        I'm glad you got the answer, otherwise I was too lazy to read the whole bunch of code.

        Comment

        Working...