473,473 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

sending email with php

54 New Member
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 1777
Dormilich
8,658 Recognized Expert Moderator Expert
try to use absolute URLs (like http://example.org/style.css)
Dec 24 '09 #2

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

Similar topics

3
by: Paul Lamonby | last post by:
Hi, I am sending a file from the server as an email attachment. The file is being attached no problem and sending the email, but I get an error when I try to open it saying it is corrupt....
0
by: praba kar | last post by:
Dear All, I have doubt regarding mail sending smtplib module. The below code is I used to send a mail. ########################################## import email.Message import email.Utils...
3
by: VB Programmer | last post by:
I have an ASPX page where I send out emails through my mail server mail.MyDomain.com. When I send emails to MyName@MyDomain.com it sends PERFECTLY. When I try sending an email to any other address...
3
by: Ant | last post by:
Hi, I'm using the MailMessage & smtpMail classes in System.Web.Mail to send mail, however it's not sending any emails. I'm using it on a Windows 2003 server. The simplest way to use this is...
1
by: Eric Sheu | last post by:
Greetings, I have been searching the web like mad for a solution to my SMTP problem. I am using Windows Server 2003 and ASP.NET 2.0 w/ C# to send out e-mails from a web site I have created to...
2
by: =?Utf-8?B?QWRl?= | last post by:
HI All, I am encountering the following error when I try to send an email through a SMTP server. I believe the problem lies with the authentication part when the network crednetials are used,...
9
by: JoeP | last post by:
Hi All, How can I find the reason for such an error: Failure sending mail. Some Code... oMailMessage.IsBodyHtml = False oMailMessage.Body = cEmailBody Dim oSMTP As New SmtpClient...
7
by: bleachie | last post by:
Hey, I just need some help, my form seems to not send me all of the 'guestNames' and 'guestEmails' forms. i use this function to add more guestnames and guestemail fields based on the number of...
10
by: Markgoldin | last post by:
I am sending an XML data from not dontnet process to a .Net via socket listener. Here is a data sample: <VFPData> <serverdata> <coderun>updateFloor</coderun> <area>MD2</area>...
31
by: happyse27 | last post by:
Hi All, I am trying for weeks how to send email from windows pc, which from my gmail account to my hotmail account. Using net::smtp module sending email failed,Kindly assist. (for the item d it...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.