Sending HTML e-mail with PHP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phptriad
    New Member
    • Jan 2006
    • 1

    Sending HTML e-mail with PHP

    :confused: Allo buddy does any one know how ti fix this.. I was sent email using mail(...) and the message email was succesed, but when the server in my Internet Provider has trouble.... the message email successed but have a problem like this

    Mailer: PHP
    X-Priority: 3
    Content-Type: text/html; charset=iso-8859-1


    <table align=center width=90%>
    <tr><td>
    <div align=justify>
    Dear Member<br><br>
    Thank you for your support towards b2b Indonesia. <br><br>

    The message not like HTML its just text...

    thanks :)
  • Niheel
    Recognized Expert Moderator Top Contributor
    • Jul 2005
    • 2432

    #2
    Common problem.

    PHP's mail function does not setup HTML mail for you automatically. No need to worry though. There are many open source classes out there that can help you extend the functionality of the mail() function.

    Here is my favorite.


    Read through the tutorial, exmpales and documentation to get the best usage out of it.
    Using HTML E-mail: http://phpmailer.sourceforge.net/tutorial.html#4

    ~ KUB

    PS. Thanks for joining our community!
    niheel @ bytes

    Comment

    • vogueves
      New Member
      • Feb 2009
      • 1

      #3
      email script

      if u did not configure the localhost to server then it will not work .
      upload it at server then plz check . thanks
      Code:
      <?php 
      if(!(isset($_SESSION['login'])))
      {
      header("location:login.php");
      }
      
      if((isset($_POST['fullName'])))
      		{
      		$fname=$_POST['fullName'];
      		$country=$_POST['country'];
      		$email=$_POST['email'];
      		$subject=$_POST['subject'];
      		$comments=$_POST['mailMessage'];
      		$headers = "From: $fname";
      		$msg="\n Name:$fullname \n From:$email \n Country:$country \n Subject:$subject\n Message:\n  $comments \n feed back from site Digitizing Zone.";
      		mail("qaiserE628@gmail.com", $subject, $msg,$headers);
      		$msg="Thank you for your feedback. Your message has been sent.";
      		}
      		
      ?>
      
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
      <link type="text/css" href="style/style-members.css" rel="stylesheet" />
      <title>Member Login</title>
      <style type="text/css">
      <!--
      .style1 {color: #FF0000}
      -->
      </style>
      <script type="text/javascript">
      
      function validateform(myform)
      {
      
      
      
      if(myform.fullName.value=="" || myform.fullName.value=="Name:")
       {
      
       alert("- Name cannot be empty");
       myform.fullName.focus();
       return false;
       }
      if(myform.country.value=="" || myform.country.value=="Country:" )
       {
      
       alert("- Company cannot be empty");
       myform.company.focus();
       return false;
       }
      
      if(myform.subject.value=="" || myform.subject.value=="Subject:")
       {
       
       alert("- Subject cannot be empty");
       myform.subject.focus();
       return false;
       }
      
      if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myform.email.value)){
      
      return true;
      }
      else
      {
      alert("Invalid E-mail Address! Please re-enter.");
      return (false);
      }
      return true;
      }
      
      function clearFun(clr)
      {
      clr.value="";
      }
      function gourl()
      {
      window.location="user.php";
      }
      
      
      
      </script>
      </head>
      <body>
      
      	<?php include("includes/uppernav-member.php");?>
      	<div id="mainbody">
      	<table width="780" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td>
      	<table border="0" cellpadding="0" cellspacing="0" width="100%" style="font:Verdana, Arial, Helvetica, sans-serif;
      	font-size:18px; font-weight:bold;">
      	<tr><td height="4px" >&nbsp;</td></tr>
      	<tr>
                                        <td colspan="3" align="center" class="td_class">E-mail us</td>
            </tr>
      	<tr>
      	  <td height="41" style="text-align:center; font-family:Verdana, Arial, Helvetica, sans-serif;
      	  font-size:10px;"><?=$msg;?></td>
      	</tr>
      	</table>	 
           	 
      	 </td>
        </tr>
      </table>
      
      				  <table width="283" border="0" align="center" cellpadding="0" cellspacing="0">
      <form name="form1" method="post" action="emailus.php" id="contactForm" onSubmit="return validateform(this);">                    
                          <tr height="30">
                            <th width="5" scope="row" ></th>
                            <th width="25" scope="row" ></th>
                            <td width="233" height="30"><label>
                            <input name="fullName" type="text"  onfocus="clearFun(this);"  value="Name:" size="30" />
                            </label></td>
                            <td width="20" rowspan="9" align="left">&nbsp;</td>
                          </tr>
                          <tr height="30">
                            <th scope="row"></th>
                            <th scope="row"></th>
                            <td><label>
                              <input name="country" type="text"  onfocus="clearFun(this);" value="Country:" size="30" />
                            </label></td>
                          </tr>
                          <tr height="30">
                            <th scope="row"></th>
                            <th scope="row"></th>
                            <td><label>
                              <input name="email" type="text"   onfocus="clearFun(this);" value="Email:" size="30" />
                            </label></td>
                          </tr>
                          <tr height="30">
                            <th scope="row"></th>
                            <th scope="row"></th>
                            <td><label>
                              <input name="subject" type="text"   onfocus="clearFun(this);" value="Subject:" size="30"/>
                            </label></td>
                          </tr>
                          <tr>
                            <th scope="row"></th>
                            <th height="30" scope="row"></th>
                            <td class="style1 style2">Comments</td>
                          </tr>
                          <tr>
                            <th scope="row"></th>
                            <th height="50" scope="row"></th>
                            <td><label>
                              <textarea name="mailMessage" cols="150" rows="100" style="width:200px; height: 160px;  overflow: auto;" onfocus="clearFun(this);"></textarea>
                            </label></td>
                          </tr>
                          <tr>
                            <th scope="row">&nbsp;</th>
                            <th scope="row">&nbsp;</th>
                            <td>&nbsp;</td>
                          </tr>
                          <tr>
                            <th scope="row">&nbsp;</th>
                            <th scope="row">&nbsp;</th>
                            <td>
                              <input type="submit" name="Submit" value="Send" style="height:25px; width:95px;"/>
                              <input type="reset" name="Submit2" value="Reset" style="height:25px; "/>
      </td>
                          </tr>
                          <tr>
                            <th scope="row">&nbsp;</th>
                            <th scope="row">&nbsp;</th>
                            <td>&nbsp;</td>
                          </tr>
      						  </form>
                          <tr>
                            <th scope="row">&nbsp;</th>
                            <th scope="row">&nbsp;</th>
                            <td><input name="button" type="button"  onclick="gourl();" value="Go Back"/></td>
                          </tr>
      						  
            </table>
      
          </div>
      	<div id="contents">
      	  
      	</div>
      <?php include("includes/footer.php");?>
      	<div style="clear:both;"></div>
      </div>
      
      <map name="Map2" id="Map2"><area shape="rect" coords="3,2,133,25" href="gallery.php" />
      </map>
      </body>
      </html>

      Comment

      Working...