•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 427,194 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,138 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 652 | Replies: 4
![]() |
•
•
Join Date: Oct 2007
Posts: 16
Reputation:
Rep Power: 1
Solved Threads: 0
Please need help I have an code for send a newsletter by the help of a good friend, but when I tried looks fine and when I open the email I received contain the newsletter picture are not appeared all necessary image are also uploaded in the same folder.
PHP CODE:
<?php
$file = 'newsletter.html';
$open = fopen($file, 'r');
$read = fread($open, filesize($file));
fclose($open);
$message =<<<MES
$read
MES;
$from = 'sender';
$subject = 'Newsletter';
$headers = "From: $from\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$hostname='h41mysql59.secureserver.net';
$username='qwertyuiop';
$password='*****';
$dbname='qwertyuiop';
$usertable='email';
$yourfield = 'email';
$con = mysql_connect("$hostname","$username","$password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$database = mysql_select_db('qwertyuiop', $con);
if (!$database) {
echo "DATABASE COULDN'T BE SELECTED";
}
$sql = "SELECT * FROM email";
$query = mysql_query($sql);
while ($row = mysql_fetch_assoc($query)) {
$to = $row['email'];
$mail = mail($to, $subject, $message, $headers);
}
if ($mail) {
echo 'All (' . mysql_num_rows($query) . ') Messages sent successfully';
}
mysql_close($con);
?>
NEWSLETTER HTML CODE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>sample</title>
<style type="text/css">
<!--
body {
background-color: #000066;
}
.style1 {
color: #FFFFFF;
font-size: xx-large;
}
.style2 {
font-size: 12px;
color: #CCCCCC;
}
-->
</style></head>
<body>
<table width="596" height="248" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<th scope="row"><p class="style1">Sample</p>
<p class="style1"> </p>
</th>
</tr>
</table>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<th background="images/newsletter_01.gif" scope="row"><p> </p>
<p> </p>
<p> </p>
<p> </p></th>
</tr>
</table>
</body>
</html>
PHP CODE:
<?php
$file = 'newsletter.html';
$open = fopen($file, 'r');
$read = fread($open, filesize($file));
fclose($open);
$message =<<<MES
$read
MES;
$from = 'sender';
$subject = 'Newsletter';
$headers = "From: $from\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$hostname='h41mysql59.secureserver.net';
$username='qwertyuiop';
$password='*****';
$dbname='qwertyuiop';
$usertable='email';
$yourfield = 'email';
$con = mysql_connect("$hostname","$username","$password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$database = mysql_select_db('qwertyuiop', $con);
if (!$database) {
echo "DATABASE COULDN'T BE SELECTED";
}
$sql = "SELECT * FROM email";
$query = mysql_query($sql);
while ($row = mysql_fetch_assoc($query)) {
$to = $row['email'];
$mail = mail($to, $subject, $message, $headers);
}
if ($mail) {
echo 'All (' . mysql_num_rows($query) . ') Messages sent successfully';
}
mysql_close($con);
?>
NEWSLETTER HTML CODE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>sample</title>
<style type="text/css">
<!--
body {
background-color: #000066;
}
.style1 {
color: #FFFFFF;
font-size: xx-large;
}
.style2 {
font-size: 12px;
color: #CCCCCC;
}
-->
</style></head>
<body>
<table width="596" height="248" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<th scope="row"><p class="style1">Sample</p>
<p class="style1"> </p>
</th>
</tr>
</table>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<th background="images/newsletter_01.gif" scope="row"><p> </p>
<p> </p>
<p> </p>
<p> </p></th>
</tr>
</table>
</body>
</html>
•
•
Join Date: Jan 2008
Posts: 55
Reputation:
Rep Power: 1
Solved Threads: 5
If I understand correctly...
The php script works fine and you received the newsletter.
The newsletter is formatted properly with the HTML.
The problem is that the pictures aren't appearing when you read the newsletter in your e-mail.
If that's the case, then you're problem may be in the way you specify the source for your images. In the HTML, you've got a reference to one image as: "images/newsletter_01.gif"
This type of relative URL won't work in an e-mail. The browser is looking for the file "images/newsletter_01.gif" inside the folder that the e-mail script is executing.
If you replace all of your relative URLs for images with absolute URLs (i.e. "http://www.mydomain.com/images/newsletter_01.gif"), they should appear correctly.
If that's not the problem, also make sure that your e-mail reader isn't blocking the images. I know that gmail blocks images by default. Some other web-based e-mail readers probably do the same thing.
Good luck,
- Walkere
The php script works fine and you received the newsletter.
The newsletter is formatted properly with the HTML.
The problem is that the pictures aren't appearing when you read the newsletter in your e-mail.
If that's the case, then you're problem may be in the way you specify the source for your images. In the HTML, you've got a reference to one image as: "images/newsletter_01.gif"
This type of relative URL won't work in an e-mail. The browser is looking for the file "images/newsletter_01.gif" inside the folder that the e-mail script is executing.
If you replace all of your relative URLs for images with absolute URLs (i.e. "http://www.mydomain.com/images/newsletter_01.gif"), they should appear correctly.
If that's not the problem, also make sure that your e-mail reader isn't blocking the images. I know that gmail blocks images by default. Some other web-based e-mail readers probably do the same thing.
Good luck,
- Walkere
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 240
You should embed your flash file in your html page.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Please review my flash CV (Website Reviews)
- form to get e-mail and name --- for newsletter (HTML and CSS)
- Php newsletter error (PHP)
- Selling advertising on an e-newsletter (Advertising Sales Strategies)
- Newsletter pop-under / Good or bad idea? (Website Reviews)
Other Threads in the PHP Forum
- Previous Thread: help
- Next Thread: Replacing 2 characters with with preg_replace



Linear Mode