jkkenzie Posted January 13, 2009 Share Posted January 13, 2009 $mail_body = "Country: ".$country."<br> Scriture date: ".$Scdate."<br> News: ".$comment; //mail body My email body looks like above. what i wanted to achieve is making paragraphs in the email and also add some images and web links. any idea how i can incorporate paragraphs, images and links? thanks, Joe Link to comment https://forums.phpfreaks.com/topic/140664-email-body/ Share on other sites More sharing options...
timmah1 Posted January 13, 2009 Share Posted January 13, 2009 You have to make sure you are using the right headers $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; Link to comment https://forums.phpfreaks.com/topic/140664-email-body/#findComment-736159 Share on other sites More sharing options...
Fahid Posted January 13, 2009 Share Posted January 13, 2009 How about this <?php function file_as_var ($file, $file_size_kilobytes = 100){ $file_size_bytes = $file_size_kilobytes * 1024; $fp = fopen($file,"r"); $output = fread($fp, $file_size_bytes); // LIMIT 100 KB fclose($fp); return $output; } $mail_body = function file_as_var ("./email_template.txt", 10); $mail_body = str_replace('__COUNTRY__',$country,$mail_body); $mail_body = str_replace('__SCDATE__',$Scdate,$mail_body); $mail_body = str_replace('__COMMENT__',$country,$mail_body); ?> while the email_template.txt should be some thing like this <p>Dear user<br>Your country is __COUNTRY__<br>Your Secure order date is __SCDATE__</p> <p>the comments are __COMMENTS__</p> You can add whatever you like in the text file, I hope this can give you the right idea at least. Link to comment https://forums.phpfreaks.com/topic/140664-email-body/#findComment-736164 Share on other sites More sharing options...
jkkenzie Posted January 14, 2009 Author Share Posted January 14, 2009 Am i able to add links and images to the text file? Link to comment https://forums.phpfreaks.com/topic/140664-email-body/#findComment-736814 Share on other sites More sharing options...
Fahid Posted January 15, 2009 Share Posted January 15, 2009 Am i able to add links and images to the text file? of course you can add whatever you want to add, you text/.txt could be a file with HTML code. or if you like, you can also use a .html file instead of .txt file. and use any of your favorite editor to create/edit this file. just be very careful at the replacement tokens i.e. __COUNTRY__ and replacement commands in PHP <?php $mail_body = str_replace('__COUNTRY__',$country,$mail_body); $mail_body = str_replace('__SCDATE__',$Scdate,$mail_body); $mail_body = str_replace('__COMMENT__',$country,$mail_body); ?> be very careful about these lines, use any number of replacement tokens you would like to, for example if I want to add a new variable into my HTML template file, I would add a line in my HTML code i.e. Your I.P. is __IP__ and add a new line ( at the end of code given below in my PHP code ) to replace __IP__ token with the user IP i.e. $mail_body = str_replace('__IP__',$_SERVER['REMOTE_ADDR'],$mail_body); End word is that: I can just give you the right direction, you have to make it to your destiny yourself Link to comment https://forums.phpfreaks.com/topic/140664-email-body/#findComment-737588 Share on other sites More sharing options...
jkkenzie Posted January 16, 2009 Author Share Posted January 16, 2009 Hey, this does not work also; the _IP_ and so on work BUT my html code in the email_template.txt which i changed to email_template.html appears as TEXT and my picture does not show , it only shows <p><img src="./images/Banner.gif" border="0" width="203" and so on... what is the problem? Link to comment https://forums.phpfreaks.com/topic/140664-email-body/#findComment-738213 Share on other sites More sharing options...
jkkenzie Posted January 16, 2009 Author Share Posted January 16, 2009 my html code looks like this: AND EVEN MY MESSAGE GOES TO JUNK EMAIL FOLDER: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>BBN .:. EMAIL</title> </head> <table width="100%"><tr><td> <table> <tr><td> <h4>Hello!, __FRIENDNAME__,</h4> <p><img src="./images/Banner.gif" border="0" width="203" height="103" />__TEXT__</p> </td></tr> <tr><td> ------------------------------------------------------------------------------------ This email is not spam. Your friend __FRIENDNAME__ invited you from IP address: __IP__ You can subscribe to our Bible Breaking News Letters by following the link at the bottom of this email message. ---------------------------------------------------------------------------------- http://www.biblebreakingnews.com/mails/subscribe.php?email=__FRIENDEMAIL__ ------------------------------------------------------------------------------------- We appreciate you taking time to read out message and you are most welcome to join BBN NEWS and even contribute your news item. ------------------------------------------------------------------------------------- </td></tr></table> </td></tr></table> <body> </body> </html> Link to comment https://forums.phpfreaks.com/topic/140664-email-body/#findComment-738215 Share on other sites More sharing options...
jkkenzie Posted January 16, 2009 Author Share Posted January 16, 2009 Any help? Link to comment https://forums.phpfreaks.com/topic/140664-email-body/#findComment-738255 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.