Miscellaneous

  Home arrow Miscellaneous arrow Page 2 - Mail() From Start To Finish
MISCELLANEOUS

Mail() From Start To Finish
By: Andrew Walsh
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 4
    2004-06-17

    Table of Contents:
  • Mail() From Start To Finish
  • Sending Html Emails
  • Sending Emails With Attachments:

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    Mail() From Start To Finish - Sending Html Emails


    (Page 2 of 3 )

    Basic text emails can be dull and not very imaginative, so if you want to have a good looking newsletter or any email you need to use html in the message. However some people think you just change your normal text message to html, and then they wonder why it displays the html code when they look in their inbox, the reason for this is that the content type is set to plain text you need to set it to html which is easily done with the header() function.

    <?php
    /* Once again we specify the variables message and 
    who the email is from and who the email is to as
    well as the subject. Notice in the headers that I
    have added content-type: text/html which makes sure
    the html is processed as html not just printed out 
    in the email */
    $message "&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body bgcolor='#EEEEEE'&gt;";
    $message .= "&lt;p align='center'&gt;This is my first html email&lt;/p&gt;";
    $message .= "&lt;/body&gt;&lt;/html&gt;";
    $from "someone@domain.com";
    $to "someone@anotherdomain.com";
    $subject "Simple Text Email";
    $headers "From: $from";
    $headers .= "Content-type: text/html\r\n"
    /* Now we are ready to send the email so we call php's mail() function
    With the appropriate variables from above included in the brackets */
    mail($to,$subject,$message,$headers);
    ?>

    More Miscellaneous Articles
    More By Andrew Walsh

    blog comments powered by Disqus

    MISCELLANEOUS ARTICLES

    - Oracle Database XE: Indexes and Sequences
    - Modifying Tables in Oracle Database XE
    - Oracle Database XE: Tables and Constraints
    - More on Oracle Databases and Datatypes
    - Oracle Database XE Datatypes: Datetime and L...
    - Oracle Database XE Datatypes: Character and ...
    - From Databases to Datatypes
    - Firefox 3.6.6 Released with Improved Plug-in...
    - Attention Bloggers: WordPress 3.0 Now Releas...
    - Reflection in PHP 5
    - Inheritance and Other Advanced OOP Features
    - Advanced OOP Features
    - Linux from Scratch V.6.6 Review
    - Linux Gaining in Strength
    - Install Slackware on Your Old PC


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 9 - Follow our Sitemap