php mail() send in html format

Discussion in 'PHP' started by easywab, Jul 8, 2008.

  1. #1
    Hi,
    I'm testing to send emails in html format using php mail().

    So I set header as follows,

    $headers .= 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";


    But style sheets are not loading ... Pls help !!
    Do I need to set text/css ??
     
    easywab, Jul 8, 2008 IP
  2. gezzle

    gezzle Peon

    Messages:
    108
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    gezzle, Jul 8, 2008 IP
  3. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #3
    Easier solution, rather than grappling with PHPMailer.

    Open this:

    http://danltn.com/bin/o0q.phps

    Save that to 'mail.php';

    Then:

    <?php
    
    require_once 'mail.php';
    
    $mail = new email;
    
    $html_mail = true;
    $to = 'them@them.com';
    $subject = 'Subject';
    $message = 'Message';
    $you = 'your@email.com';
    
    $mail->html_mail($html_mail)->to($to)->subject($subject)->message($message)->from($you)->send();
    
    PHP:
     
    Danltn, Jul 8, 2008 IP
  4. Mozzart

    Mozzart Peon

    Messages:
    189
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Oh nice class, although I wish it had a setCharset('UTF-8') along with it to apply in html_mail :)
     
    Mozzart, Jul 8, 2008 IP
  5. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #5
    Yeah I'll update that I guess.

    Dan
     
    Danltn, Jul 8, 2008 IP
  6. zerofill

    zerofill Member

    Messages:
    34
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    45
    #6
    Code I used before awhile back to send HTML email

     
    zerofill, Jul 8, 2008 IP
  7. zerofill

    zerofill Member

    Messages:
    34
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    45
    #7
    Ahh style sheets you mentioned...I dunno that I sent anything but basic HTML with what I just put...
     
    zerofill, Jul 8, 2008 IP