Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

sending email with php

0 views
Skip to first unread message

Sudhakar

unread,
Dec 23, 2009, 4:02:24 PM12/23/09
to
<?php

$headers = "Content-type: text/html; charset=iso-8859-1";
$to="myemailaddress";
$subject="Email Newsletter";

$message = '<!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>
<title>Email Newsletter</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex, nofollow" />
<link rel="stylesheet" type="text/css" href="style.css" />
</head>

<body>
<div id="wrapper">
<div id="topmenu">
</div>
<div id="content">
<div class="leftcolumn">
</div>
<div class="rightcolumn">
</div>
</div>
<div id="footer">
</div>
</div>
</body>
</html>';

if(! mail($to, $subject, $message, $headers)){
echo "There was an error is sending the email";
}
else{
echo "The email has been sent";
}
?>

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
$headers = "Content-type: text/html; charset=iso-8859-1";
$to="myemailaddress";
$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

The Natural Philosopher

unread,
Dec 23, 2009, 5:23:08 PM12/23/09
to


This is what I use.

You must not use style sheets - just emebd th styles, and if sending to
Outlook it cant handle divs, only basic formatting and tables.

function mail_html_file($email, $subject,$from,$return_path,$body)
{

$attach=
chunk_split(base64_encode(file_get_contents('../Images/Logo2.gif')));
$boundary = md5( time() );

$headers = sprintf("From: %s\nMIME-Version: 1.0\nContent-Type:
multipart/related; boundary=\"%s\"",
$from, $boundary);

$message = sprintf("--%s\nContent-Type: text/html;
charset=\"iso-9959-1\"\nContent-Transfer-Encoding:
quoted-printable\n\n%s\n\n--%s\nContent-Type: Image/gif;
name=\"Logo.gif\"\nContent-ID: <Logo2.gif>\nContent-Transfer-Encoding:
base64\n\n%s\n\n--%s--\n",
$boundary,$body,$boundary,$attach,$boundary);
mail($email, $subject, $message, $headers, "-f ".$return_path );
}

Andy

unread,
Dec 24, 2009, 3:07:11 AM12/24/09
to

"Sudhakar" <sudhak...@gmail.com> wrote in message
news:6523b4c4-2e3a-4001...@m33g2000pri.googlegroups.com...

Hi,


Use this...

http://phpmailer.worxware.com/index.php?pg=phpmailer


it's free, powerful, easy and secure. I use it.


Andy

Jerry Stuckle

unread,
Dec 24, 2009, 8:31:35 AM12/24/09
to

I concur 100% - much easier to use.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstu...@attglobal.net
==================

Andy

unread,
Dec 25, 2009, 5:51:43 AM12/25/09
to

"Jerry Stuckle" <jstu...@attglobal.net> wrote in message
news:hgvqfq$9nc$2...@news.eternal-september.org...


Whohooooo, I got an "I concur" ;)

Happy Christmas


Andy

0 new messages