Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Sending an HTML e-mail using mail() command

BBeennBBeenn Member Posts: 44
Hello,
I am trying to send an HTML e-mail using the mail() command.
However, the e-mail that I receive looks like:

Subscription Request For:

E-mail Address: kk@ll.com

Name: lllkkk

This appeares as plain text with all the tags showing

My mail command is:

mail($sendto,$subject,$message,"From: "News Subscription" <$address>");

Could someone please help me send it as HTML not text.
Thanks
BBeenn

Comments

  • jeskejeske Member Posts: 23
    : Hello,
    : I am trying to send an HTML e-mail using the mail() command.
    : However, the e-mail that I receive looks like:
    :
    :

    Subscription Request For:

    E-mail Address: kk@ll.com

    Name: lllkkk

    :
    : This appeares as plain text with all the tags showing
    :
    : My mail command is:
    :
    : mail($sendto,$subject,$message,"From: "News Subscription" <$address>");
    :
    : Could someone please help me send it as HTML not text.
    : Thanks
    : BBeenn
    :
    Hi,
    To send strictly an HTML message, you need to add a MIME-type header.
    A complete, simple example is included below.



    Hello World


    Hello World

    ";

    ### Mail Header with return address and HTML MIME-type ###
    $mailheader = "From: someone@somewhere.com
    Content-Type: text/html

    ";

    ### Combine the pieces and send the message ###
    mail($sendto,$subject, $msg, $mailheader);
    ?>
    Technically, it's probably a better idea to send a multi-part message that includes both a plain-text version and an HTML version.

    Hope this helps.

    Jeff
  • BBeennBBeenn Member Posts: 44
    : : Hello,
    : : I am trying to send an HTML e-mail using the mail() command.
    : : However, the e-mail that I receive looks like:
    : :
    : :

    Subscription Request For:

    E-mail Address: kk@ll.com

    Name: lllkkk

    : :
    : : This appeares as plain text with all the tags showing
    : :
    : : My mail command is:
    : :
    : : mail($sendto,$subject,$message,"From: "News Subscription" <$address>");
    : :
    : : Could someone please help me send it as HTML not text.
    : : Thanks
    : : BBeenn
    : :
    : Hi,
    : To send strictly an HTML message, you need to add a MIME-type header.
    : A complete, simple example is included below.
    :
    : <?
    : ### Create HTML Message ###
    : $sendto = "someone@somewhere.com";
    : $subject = "Hello World";
    : $msg = "
    : <html>
    :
    : Hello World
    :
    :
    :


    : Hello World
    :

    :
    : ";
    :
    : ### Mail Header with return address and HTML MIME-type ###
    : $mailheader = "From: someone@somewhere.com
    Content-Type: text/html

    ";
    :
    : ### Combine the pieces and send the message ###
    : mail($sendto,$subject, $msg, $mailheader);
    : ?>
    : Technically, it's probably a better idea to send a multi-part message that includes both a plain-text version and an HTML version.
    :
    : Hope this helps.
    :
    : Jeff
    :

    How would I do that?
    Thanks

  • jeskejeske Member Posts: 23
    : How would I do that?
    : Thanks
    :
    :
    You can probably Google numerous articles about it, but WebMasterBase has an article by Kevin Yank that covers Email in PHP from basic plain-text messages up through multiparts.

    http://www.webmasterbase.com/article/679/

    Jeff
  • BBeennBBeenn Member Posts: 44
    : : Hello,
    : : I am trying to send an HTML e-mail using the mail() command.
    : : However, the e-mail that I receive looks like:
    : :
    : :

    Subscription Request For:

    E-mail Address: kk@ll.com

    Name: lllkkk

    : :
    : : This appeares as plain text with all the tags showing
    : :
    : : My mail command is:
    : :
    : : mail($sendto,$subject,$message,"From: "News Subscription" <$address>");
    : :
    : : Could someone please help me send it as HTML not text.
    : : Thanks
    : : BBeenn
    : :
    : Hi,
    : To send strictly an HTML message, you need to add a MIME-type header.
    : A complete, simple example is included below.
    :
    : <?
    : ### Create HTML Message ###
    : $sendto = "someone@somewhere.com";
    : $subject = "Hello World";
    : $msg = "
    : <html>
    :
    : Hello World
    :
    :
    :


    : Hello World
    :

    :
    : ";
    :
    : ### Mail Header with return address and HTML MIME-type ###
    : $mailheader = "From: someone@somewhere.com
    Content-Type: text/html

    ";
    :
    : ### Combine the pieces and send the message ###
    : mail($sendto,$subject, $msg, $mailheader);
    : ?>
    : Technically, it's probably a better idea to send a multi-part message that includes both a plain-text version and an HTML version.
    :
    : Hope this helps.
    :
    : Jeff
    :

    How would I do that?
    Thanks

  • BBeennBBeenn Member Posts: 44
    Sorry about that last post by me. I went to a page in my history and it posted a previous post again.

  • BBeennBBeenn Member Posts: 44
    Sorry about that last post by me. I went to a page in my history and it posted a previous post again.

  • Andre YoungAndre Young USAMember Posts: 0

    ___ \ http://forcoder.org \ free video tutorials and ebooks about | R, Scratch, Python, Visual Basic, MATLAB, Java, C, PL/SQL, Assembly, Ruby, Visual Basic .NET, PHP, Objective-C, C#, Perl, JavaScript, C++, Delphi, Go, Swift F#, Crystal, Fortran, FoxPro, Logo, Alice, Rust, Lisp, D, Prolog, ML, Scala, Awk, Clojure, Transact-SQL, Julia, LabVIEW, Dart, VBScript, Bash, Ada, Apex, Kotlin, COBOL, SAS, Erlang, ABAP, Hack, Scheme, Lua | _________

Sign In or Register to comment.