This is a discussion on html e-mails from mail() within the alt.comp.lang.php forums, part of the PHP Programming Forums category; I've been using a function that uses mail() to try ant send a html e-mail, with little sucess - ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I've been using a function that uses mail() to try ant send a html e-mail,
with little sucess - the html displays as plaintext in the e-mail body. I know about MIME, but I'm not really sure how to implement it in PHP without using a pipe to sendmail. Is there a good tutorial on the net - I've looked, but can only find e-books and the like and I need a tutorial that's short and to the point. Cheers, Dave. |
|
|||
|
Problem solved - I've found out that it's best to have the headers as strigs
in the mail() command it's self - variables don't seem to work well. Cheers, David. "Dafydd Monks" <dafydd.monks@dragondesigns.org.uk> wrote in message news:cemc4d$rsn$1@newsg4.svr.pol.co.uk... > I've been using a function that uses mail() to try ant send a html e-mail, > with little sucess - the html displays as plaintext in the e-mail body. > > I know about MIME, but I'm not really sure how to implement it in PHP > without using a pipe to sendmail. > > Is there a good tutorial on the net - I've looked, but can only find e-books > and the like and I need a tutorial that's short and to the point. > > Cheers, > > Dave. > > |
|
|||
|
$from = "me@mydomain.com";
$username = "Georgey Porgey"; $email = "pudding@pie.com"; $message = "This is a bold-face test!"; $headers = "MIME-Version: 1.0\r\n" . "Content-type: text/html; charset=iso-8859-1\r\n" . "To: $username <$email>\r\n" . "From: $from\r\n" . "X-Mailer: PHP " . phpversion() . "\r\n" . "Reply-to: $from"; $body =<<<END <html> <head> <style type="text/css" media="screen"> ..test { font-weight: bolder; } </style> </head> <body> <span class="test">$message</span> </body> </html> END; $sendmailargs = "-f " . $from; if (mail('', $subject, $body, $headers, $sendmailargs)) { print("Successful email sent"); } else { print("Poo, email didn't send."); } Minus some minor details--factual email addresses namely--the code above works perfectly every time, and you can see I'm using variables all over the place. Now, one thing I did have a problem with is my sendmail being set up and running correctly--imagine my surprise on the very day I got sendmail configured correctly I start getting test mail()'s I tried sending last year--but didn't have the time to track. ;) Oh, and before I forget, if you supply a To header, don't put anything for the first arguement of mail(), and vice versa. On Tue, 3 Aug 2004 00:01:44 +0100, "Dafydd Monks" <dafydd.monks@dragondesigns.org.uk> wrote: >Problem solved - I've found out that it's best to have the headers as strigs >in the mail() command it's self - variables don't seem to work well. > >Cheers, > >David. > >"Dafydd Monks" <dafydd.monks@dragondesigns.org.uk> wrote in message >news:cemc4d$rsn$1@newsg4.svr.pol.co.uk... >> I've been using a function that uses mail() to try ant send a html e-mail, >> with little sucess - the html displays as plaintext in the e-mail body. >> >> I know about MIME, but I'm not really sure how to implement it in PHP >> without using a pipe to sendmail. >> >> Is there a good tutorial on the net - I've looked, but can only find >e-books >> and the like and I need a tutorial that's short and to the point. >> >> Cheers, >> >> Dave. >> >> > |
![]() |
| Thread Tools | |
| Display Modes | |
|
|