It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming HTML Forum

html emails

html emails

Postby joshcxa on Thu Jul 21, 2005 3:28 am

How do I create those html emails.
You know the ones that look like a website in your inbox.
joshcxa
DEVPPL Lightwave Moderator
User avatar
joshcxa
100+ Club
 
Posts: 156
Joined: Wed Aug 18, 2004 10:59 am
Location: Australia

Postby webmaster on Thu Jul 21, 2005 8:16 am

The only thing that makes an email to be shown as HTML is something called header information. when you send the email, you first declare what kind of document you're sending. Here's an example of a HTML e-mail:

[php]<?php
$to = "johndoe@fakedomain.com";
$from = "janedoe@anotherfakedomain.com";
$subject = "This is a test email";
$message = <<<EOF
<html>
<body bgcolor="#ffffff">
<p align="center">
<b>Hello World!</b>
</p>
</body>
</html>
EOF;

$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";

$success = mail($to, $subject, $message, $headers);
if ($success)
echo "The email to $to from $from was successfully sent";
else
echo "An error occurred when sending the email to $to from $from";
?> [/php]
Make sure to check out our TNX Review and Link Vault Review
User avatar
webmaster
Site Admin
 
Posts: 2695
Joined: Tue Aug 17, 2004 1:07 pm
Location: Sweden

Postby Phate on Thu Jul 21, 2005 3:05 pm

wow, i never knew you could do that!
Web-Developing since '03
Image
User avatar
Phate
500+ Club
 
Posts: 826
Joined: Sun Nov 21, 2004 4:12 am
Location: 127.0.0.1

Postby joshcxa on Fri Jul 22, 2005 2:57 am

so what do i do with that?
joshcxa
DEVPPL Lightwave Moderator
User avatar
joshcxa
100+ Club
 
Posts: 156
Joined: Wed Aug 18, 2004 10:59 am
Location: Australia

Postby webmaster on Fri Jul 22, 2005 8:22 am

joshcxa wrote:so what do i do with that?
I don't know how to do it with plain html, but with php, you could use the first script I posted.

Just change $to, $from and $subject and $message and you can send a html e-mail.
Make sure to check out our TNX Review and Link Vault Review
User avatar
webmaster
Site Admin
 
Posts: 2695
Joined: Tue Aug 17, 2004 1:07 pm
Location: Sweden

Postby joshcxa on Fri Jul 22, 2005 12:55 pm

but what i mean is...do i have that code in a seperate file attachted to the email?
joshcxa
DEVPPL Lightwave Moderator
User avatar
joshcxa
100+ Club
 
Posts: 156
Joined: Wed Aug 18, 2004 10:59 am
Location: Australia

Postby webmaster on Fri Jul 22, 2005 1:02 pm

This code sends the e-mail. If you save this code in a file called mailscript.php, upload it to your server and run www.yourdomain.com/mailscript.php it will send a html-mail to the e-mail address in the top of the script.
Make sure to check out our TNX Review and Link Vault Review
User avatar
webmaster
Site Admin
 
Posts: 2695
Joined: Tue Aug 17, 2004 1:07 pm
Location: Sweden

Postby joshcxa on Mon Jul 25, 2005 2:51 pm

oh ok...but what about for a mailing list type thing?
joshcxa
DEVPPL Lightwave Moderator
User avatar
joshcxa
100+ Club
 
Posts: 156
Joined: Wed Aug 18, 2004 10:59 am
Location: Australia

Postby ReFredzRate on Mon Jul 25, 2005 5:28 pm

joshcxa wrote:oh ok...but what about for a mailing list type thing?

I assume you are talking about a webpage styled e-mail you receive?
ReFredzRate
1000+ Club
 

Postby joshcxa on Tue Jul 26, 2005 5:04 am

yep
joshcxa
DEVPPL Lightwave Moderator
User avatar
joshcxa
100+ Club
 
Posts: 156
Joined: Wed Aug 18, 2004 10:59 am
Location: Australia

Next

Who is online

Users browsing this forum: No registered users and 4 guests