sending email with php

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


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

$message = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//
EN" " ">
<html xmlns=" ">
<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" />

<div id="wrapper">
    <div id="topmenu">
    <div id="content">
        <div class="leftcolumn">
        <div class="rightcolumn">
    <div id="footer">

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


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";
$subject="Email Newsletter";
$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 i
am getting a message that The email has been sent and i am getting the

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

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.


Re: sending email with php

Sudhakar wrote:
Quoted text here. Click to load it

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)
    $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;
quoted-printable\n\n%s\n\n--%s\nContent-Type: Image/gif;
name=\"Logo.gif\"\nContent-ID: <Logo2.gif>\nContent-Transfer-Encoding:
      mail($email, $subject, $message, $headers, "-f ".$return_path );

Re: sending email with php

Quoted text here. Click to load it


Use this...

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


Re: sending email with php

Andy wrote:
Quoted text here. Click to load it

I concur 100% - much easier to use.

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Re: sending email with php

Quoted text here. Click to load it

Whohooooo, I got an "I concur" ;)

Happy Christmas


Site Timeline