Current location: Hot Scripts Forums » Programming Languages » PHP » Mail using html format


Mail using html format

Reply
  #1 (permalink)  
Old 12-11-03, 11:35 AM
woyrz's Avatar
woyrz woyrz is offline
Newbie Coder
 
Join Date: Dec 2003
Location: montreal
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Question Mail using html format

Hi

I am trying to build a template in html to do my e-mail. Using the aministration pannel some could comme typing the the email content and hit send. The template is automaticly apply and send to all the pepoel in the database using the mail() fonction.

So far what i have is working perfecly but the email is sent in whatever format that not show the html as html content. So the use get all the html code!!! So enoying !!!

<?php
mysql_connect("localhost", "user","somme passe") or die (mysql_error());
mysql_select_db("mydatabase") or die(mysql_error());

$sql = mysql_query("SELECT * FROM `table` WHERE lang='fr'");
//$result = mysql_query($sql,$db) or die (mysql_error());
while ($mafonction = mysql_fetch_array($sql)) {
$email= $mafonction ['email'];

$msg = "<a href=\"http://wwww.mediaflexdesign.com/index.php?username=$email\">test</a>";
$recipient = "$email";
$subject = "Your chrimast card";
$mailheaders = "From: Media flex design site web <admin@mediaflexdesign.com>\n";
$mailheaders .= "Reply-To: <admin@mediaflexdesign.com>\n\n";

mail($recipient, $subject, $msg, $mailheaders);

}
?>

I need help !!!

please
Woyrz
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 12-11-03, 11:39 AM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
Try removong the // from your query....

//$result = mysql_query($sql,$db) or die (mysql_error());

to this

$result = mysql_query($sql,$db) or die (mysql_error());

"//" makes the line a comment, i believe, so it may be blocking the results from actually being processed.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 12-11-03, 11:43 AM
woyrz's Avatar
woyrz woyrz is offline
Newbie Coder
 
Join Date: Dec 2003
Location: montreal
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Question

Quote:
Originally Posted by mdhall
Try removong the // from your query....

//$result = mysql_query($sql,$db) or die (mysql_error());

to this

$result = mysql_query($sql,$db) or die (mysql_error());

"//" makes the line a comment, i believe, so it may be blocking the results from actually being processed.

it's not woriking. the e-mail is sent!! i have not prob with that is juste in the format. Is sendding the email in text format when it whoud send it in html format

Woyrz

Last edited by woyrz; 12-11-03 at 12:28 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 12-11-03, 12:30 PM
hyjacked hyjacked is offline
Wannabe Coder
 
Join Date: Nov 2003
Location: New Brunswick, Canada
Posts: 174
Thanks: 0
Thanked 0 Times in 0 Posts
mdhall, he is hardcoding data in below that.

An obvious question but I'll ask anyways. Does the email program support html?
__________________
hyjacked
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 12-11-03, 12:32 PM
woyrz's Avatar
woyrz woyrz is offline
Newbie Coder
 
Join Date: Dec 2003
Location: montreal
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation

Quote:
Originally Posted by hyjacked
mdhall, he is hardcoding data in below that.

An obvious question but I'll ask anyways. Does the email program support html?

yes i does

Last edited by woyrz; 12-11-03 at 12:37 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 12-11-03, 12:52 PM
hyjacked hyjacked is offline
Wannabe Coder
 
Join Date: Nov 2003
Location: New Brunswick, Canada
Posts: 174
Thanks: 0
Thanked 0 Times in 0 Posts
I couldn't come up with anything besides you are missing a setting that would tell it to send it as html email, but even that doesn't make sense. I would almost think it is more of a problem on the email client side then the server sending.

here is the php.net page for mail():
http://www.php.net/manual/en/ref.mail.php

edit:
Actually I just found this, took it from the above link about 3/4 of the down the page into the user submitted comments. Try merging this into your code.
PHP Code:

// html section 

 
$Msg.="\n--".$IB."\n";
 
$Msg.="Content-Type: text/html;\n\tcharset=\"iso-8859-1\"\n";
 
$Msg.="Content-Transfer-Encoding: base64\n\n";
 
// html goes here 
 
$Msg.=chunk_split(base64_encode($Html))."\n\n"
__________________
hyjacked
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 12-11-03, 12:59 PM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
Ok, guess I misunderstood the problem he was having.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 12-12-03, 09:12 AM
whiteraider whiteraider is offline
Newbie Coder
 
Join Date: Dec 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Code:

/*basic mail settings */

$Msg="some HTML message";
$subject  "some subject";
$headers  "MIME-Version: 1.0;\n";
$headers .= "Content-type: text/html; charset=iso-8859-1;\n";

/* additional headers */
//$headers .= "To: webmaster <webmaster@somedomain.com>;\n";
$headers .= "From: Errors <errors@somedomain.com>;\n";
$headers .= "Cc: [email]admin@somedomain.com[/email];\n";
$headers .= "Bcc: [email]another.boss@somedomain.com[/email];\n";

/* and now mail it */
mail($to$subject$Msg$headers); 
This is the code that I use to mail a html table from one of my sites

The $headers TO field is commented out because the server uses QMail which has a bug that sends a copy of the mail for any TO field, so 2 copies get sent not 1.

Also note that there is a ; (semi-colon) at the end of each header, this also is needed otherwise the message gets sent as text. - This had me stumped for a while as my test server didn't need them!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
formmail problem gscraper Perl 12 08-27-04 04:06 AM
Announcement: Mojo Mail is now Dada Mail skazat General HotScripts Site Discussion 0 12-07-03 11:10 PM
Email problem haichandra ASP 2 11-01-03 02:15 AM
Formmail 1.92 - Send HTML Mail Foochuck Perl 0 10-28-03 04:43 PM
help plz: format retrieved Mysql data in HTML with PHP paulj000 PHP 2 10-19-03 09:03 PM


All times are GMT -5. The time now is 10:13 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.