Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Oct 2007
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Sending HTML email from php. where am i going wrong?

    i'm trying to get php to send a html email from a page, here is my source code, what am i doing wrong?

    PHP Code:
    <?php
        $emailaddress 
    'Test@Email.com';
        
    $fullame 'Full Name';
        
    $to $emailaddress;
        
    $subject "Aknowledgement";
        
    $body "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta http-equiv=\"Content-Type\" content=\"text/html;" .
        
    "charset=iso-8859-1\" /><style>" .
        
    "body, p{font-family: Trebuchet MS, verdana;color: #666666;font-size:12px;}" .
        
    "a, a:visited{font-family:Trebuchet MS, verdana;text-decoration: underline;color: #6C408D;font-size:12px;}" .
        
    "a:hover{font-family:Trebuchet MS, verdana;text-decoration: none;color: #6C408D;font-size:12px;}" .
        
    "</style></head><p>Dear " $fullname ",</p><p>Thank you for your request.</p>" .
        
    "<p>We will contact you shortly.</p>" .
        
    "<p>Regards</p><p><strong>Visit our website:</strong> <a href=\"#\" target=\"_blank\">#</a>";
        
    $headers "From: emailsender@Email.com\n" .
            
    "X-Mailer: php\n" .
            
    "Content-type: text/html; charset=iso-8859-1";
        
    mail($emailaddress$subject$body$headers);
        echo(
    "mail SENT to:"$emailaddress"!");
    ?>
    any help is greatly appreciated.

  • #2
    Regular Coder
    Join Date
    Dec 2007
    Location
    Nebraska
    Posts
    113
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Thanks to spammers, sending automated email with PHP is a little bit of a dark art.

    I would strongly suggest using a pre-written mail class such as PHPMailer, Zend Mail or PEAR::mail (to name a few). These classes have proven code in them and allow you to send both plain text and HTML versions of your message.

    Sending mail with PHP just isn't as simple as using the mail function (which doesn't actually send mail BTW) anymore.
    Deliver yesterday, code today, think tomorrow.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •