mail not sent when headers are used

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vjayis
    New Member
    • Mar 2008
    • 134

    mail not sent when headers are used

    hi
    i m using mail() function to send mails and it works well for an sample message without including headers.,

    when i include headers and send an html content or an sample content i didnt receive an mails ., no mails in spam folder too..

    here is my code:

    Code:
    <?php
    $fname='vijay';
    $header="MIME-Version: 1.0\r\n"; 
    $header.="Content-type: text/plain; charset=iso-8859-1\r\n"; 
    $header.="From: ".$fname." <from@example.com>\r\n";
    
    $msg='
    <table width="100%" cellspacing="0" cellpadding="0">
      <tr>
        <th align="right" valign="top" scope="row">Name</th>
        <th align="left" valign="top" scope="row">&nbsp;</th>
        <th align="left" valign="top" scope="row">Vijay</th>
      </tr>
      <tr>
        <th align="right" valign="top" scope="row">Address</th>
        <th align="left" valign="top" scope="row">&nbsp;</th>
        <th align="left" valign="top" scope="row">Madurai</th>
      </tr>
      <tr>
        <th align="right" valign="top" scope="row">Tel</th>
        <th align="left" valign="top" scope="row">&nbsp;</th>
        <th align="left" valign="top" scope="row">9876543210</th>
      </tr>
    </table>
    ';
    
    $subject="testing".date('d-M-Y H:i:s');
    $to='to@example.com';
    
    mail($to,$subject,$msg,$header);
    
    echo "success";
    ?>
    i got the message "success" printed but no mails received.

    thanks
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    you always get printed "success", even if the mail() function fails. you have to explicitly test the function’s return value to make sure.

    Comment

    • vjayis
      New Member
      • Mar 2008
      • 134

      #3
      tried using
      Code:
      <?php
      $return=mail($to,$subject,$msg,$header);
      echo "success";
      var_dump($return);
      echo $return;
      
      ?>
      and got result as

      successbool(fal se)

      so what do i want to do..

      Comment

      Working...