469,950 Members | 1,964 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,950 developers. It's quick & easy.

sending email with php

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. $headers = "Content-type: text/html; charset=iso-8859-1";
  4. $to="myemailaddress";
  5. $subject="Email Newsletter";
  6.  
  7. $message = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  8. <html xmlns="http://www.w3.org/1999/xhtml">
  9. <head>
  10. <title>Email Newsletter</title>
  11. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  12. <meta name="robots" content="noindex, nofollow" />
  13. <link rel="stylesheet" type="text/css" href="style.css" />
  14. </head>
  15.  
  16. <body>
  17. <div id="wrapper">
  18.     <div id="topmenu">
  19.     </div>
  20.     <div id="content">
  21.         <div class="leftcolumn">
  22.         </div>
  23.         <div class="rightcolumn">
  24.         </div>
  25.     </div>
  26.     <div id="footer">
  27.     </div>
  28. </div>
  29. </body>
  30. </html>';
  31.  
  32. if(! mail($to, $subject, $message, $headers)){
  33.     echo "There was an error is sending the email";
  34.     }
  35.     else{
  36.     echo "The email has been sent";
  37.     }
  38. ?>
hi

my question is about send an email with php like a newsletter, when we read a newsletter email its similar to a webpage which contains content, images, css and other elements

i created a static webpage initially with html css and images folder after creating the page i wanted to test to see how it would look if i were to send this as an email like a newsletter.

so i have created a php file with
Expand|Select|Wrap|Line Numbers
  1. $headers = "Content-type: text/html; charset=iso-8859-1";
  2. $to="myemailaddress";
  3. $subject="Email Newsletter";
and
$message as mentioned above has the entire html code as i used it in my static html page
i also copied the style.css in the server and created images folder and copied all the images i used in my static page to the server.

i created a separate folder in my webserver called newsletter and copied the php file, css file and images folder with the images i used

when i accessed the index.php as http://website.com/emailnewsletter i am getting a message that The email has been sent and i am getting the email

however my question is when i open this email the styles and images are not being applied and i see only the text in the static page i created.


can someone let me know how i can fix this so that when i open the email it would look like the static page i created with all the styles applies and images displayed

is this only possible by using specialized email softwares or can it be done by php as well with the logic used.


any help will be appreciated.

thanks
Dec 23 '09 #1
1 1632
Dormilich
8,652 Expert Mod 8TB
try to use absolute URLs (like http://example.org/style.css)
Dec 24 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Paul Lamonby | last post: by
reply views Thread by praba kar | last post: by
3 posts views Thread by Ant | last post: by
2 posts views Thread by =?Utf-8?B?QWRl?= | last post: by
7 posts views Thread by bleachie | last post: by
10 posts views Thread by Markgoldin | last post: by
31 posts views Thread by happyse27 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.