Jump to content

Newletter image header


ayok

Recommended Posts

Hi.. I'm a newbie here, also to PHP.

NOw I have a question about php newsletter. I have a simple newsletter script which use .txt database.for the emails. Everything works fine.

 

However, I want an image header on the mail body.. like logo. So everytime I send my newsletter, the image will appear on the top of the mail body. But I can't get it. Could anybody tell me how to do it? Here is part of the php script for the email.

<?php
include "config.php";
include "header.inc";
if(!($sendmail)){
?>

<form method="POST" action="<?php echo($PHP_SELF); ?>">

<h3>News </h3>
  <p>Select Mailing List:<br>
  <select size="1" name="list_choice">
    <option selected>emails.txt</option>
    
  </select></p>
  <p>Title:<br>
  <input type="text" name="subject_choice" size="50"></p>
  <p>Message:<br>
  <textarea rows="6" name="message_choice" cols="42"></textarea></p>
  <p><input type="submit" value="Send Mail" name="sendmail"><input type="reset" value="Reset" name="B2"></p>
</form>
</UL>
<?php
}
$header = "From: $from_mail; \n";
if ($sendmail == "Send Mail"){

print ("<H3>Sending news to emails...</H3><P>");

$file_handle = fopen($list_choice, "r") or die("Couldn't open mailing list..");

while (!feof($file_handle)) {
set_time_limit(0);
$address = fgets($file_handle, 1024);

mail("$address", stripslashes($subject_choice), 
stripslashes($message_choice), $header);
print ("Mail Sent To: $address<br>\n");

}
print ("<H3>Done! The news is sent.  Klik <A HREF='view.php'>Click here</A> to see the emails.</H3><BR>");
}
include "footer.inc";
?>

Link to comment
https://forums.phpfreaks.com/topic/38075-newletter-image-header/
Share on other sites

Thanks Greaser!

yes, $message_choice will be the body. The message will be filled in a news form, and sent directly without being saved to any database.

 

I think that is my question, how can i include the picture into the $message_choice file? I got this script from a php tut, but they don't discuss about include the picture.

 

Thx.

ayoksus

Since your $message file is php you can use html in that file. If your not that familiar with html the following code is what you will need to display that picture:

<img src="Action" width="width_in_pixels" height="height_in_pixels">

Where it says action you need to input the location that you picture is located such as "yoursitename.com/images"

Then all you need to do is place the code I gave you wherever you want the picture to be in your $message file--possibly the header since you said at the top.

 

<?php
include "config.php";
include "header.inc";
if(!($sendmail)){
?>

<form method="POST" action="<?php echo($PHP_SELF); ?>">

<h3>News </h3>
  <p>Select Mailing List:<br>
  <select size="1" name="list_choice">
    <option selected>emails.txt</option>
    
  </select></p>
  <p>Title:<br>
  <input type="text" name="subject_choice" size="50"></p>
  <p>Message:<br>
  <textarea rows="6" name="message_choice" cols="42"></textarea></p>
  <p><input type="submit" value="Send Mail" name="sendmail"><input type="reset" value="Reset" name="B2"></p>
</form>
</UL>
<?php
}
$headers = "From: [email protected]\r\n" .
       'X-Mailer: PHP/' . phpversion() . "\r\n" .
       "MIME-Version: 1.0\r\n" .
       "Content-Type: text/html; charset=utf-8\r\n" .
       "Content-Transfer-Encoding: 8bit\r\n\r\n";
       
if ($sendmail == "Send Mail"){

print ("<H3>Sending news to emails...</H3><P>");

$file_handle = fopen($list_choice, "r") or die("Couldn't open mailing list..");

while (!feof($file_handle)) {
set_time_limit(0);
$address = fgets($file_handle, 1024);

mail("$address", stripslashes($subject_choice), 
stripslashes($message_choice), $headers);
print ("Mail Sent To: $address<br>\n");

}
print ("<img src='http://www.what_ever.com/image.gif'></img><br>


<H3>Done! The news is sent.  Klik <A HREF='view.php'>Click here</A> to see the emails.</H3><BR>");
}
include "footer.inc";
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.