Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
sending email with php
Old 12-23-2009, 04:13 PM sending email with php
Ultra Talker

Posts: 254
Trades: 0
PHP Code:
<?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

Last edited by chrishirst; 12-23-2009 at 04:15 PM..
sudhakararaog is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-23-2009, 05:08 PM Re: sending email with php
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
It can be done in php, sure, but you will need to embed everything that's needed into the mail.

Mail reader today have policies that (by default) disallow a mail to fetch it's content from a web site, to prevent malicious usage.

In your case, every image, script and style sheets are restricted, giving you just the bare HTML.

There are many libraries that allow you to make this an easy job.
Looking a bit, I've found Rmail ( http://www.phpguru.org/downloads/htm...l%20for%20PHP/ ) which seems to do a fine job.

As a rule of thumb, I'd remove external style sheet and put them in a <style> tag into the mail. Because I'm not sure you can embedd a css stylesheet in the mail that will be use.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 12-23-2009, 05:19 PM Re: sending email with php
Ultra Talker

Posts: 254
Trades: 0
thanks for letting me know
sudhakararaog is offline
Reply With Quote
View Public Profile
 
Old 12-24-2009, 12:24 AM Re: sending email with php
Ultra Talker

Posts: 254
Trades: 0
initially i used a repeating background using css by specifying repeat-x for a div that holds the background image, when i tested this by sending an email using php i noticed that when i clicked view images in gmail i am able to see all the images i used as <img> tag specifying its absolute path, but not repeating background using css

so i tried using the repeating background inside a <td> which repeated fine when i access the page on my local machine and from a server, however when i used it for the email example , even with <td> tag gmail is not able to repeat the background image, i would image this would be the case with other email clients as well, is there any workaround for repeating backgrounds either as repeat-x or repeat-y for email clients in this case when sending an email from a php file

thanks
sudhakararaog is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to sending email with php
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.50201 seconds with 12 queries