ayok Posted February 11, 2007 Share Posted February 11, 2007 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"; ?> Quote Link to comment Share on other sites More sharing options...
ayok Posted February 12, 2007 Author Share Posted February 12, 2007 Nobody can help? Or my english is too bad? Quote Link to comment Share on other sites More sharing options...
ayok Posted February 13, 2007 Author Share Posted February 13, 2007 Is this a silly question? why can't i get any answer in any php forums? ??? ??? Quote Link to comment Share on other sites More sharing options...
trecool999 Posted February 13, 2007 Share Posted February 13, 2007 No, your English is fine, I just don't get it... are you trying to insert an image at the top of the Email? Quote Link to comment Share on other sites More sharing options...
ayok Posted February 14, 2007 Author Share Posted February 14, 2007 Hey thanx... Yes, I'd like to have a picture in the emails i sent to the subscribers. You know, like a letter with a header on the top of the letter, like logo. Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted February 14, 2007 Share Posted February 14, 2007 I take it that $message_choice is the actual body that you are sending to the people via e-mail? If this is true why not just include the picture at the top of your $message_choice file? Quote Link to comment Share on other sites More sharing options...
ayok Posted February 14, 2007 Author Share Posted February 14, 2007 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 Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted February 14, 2007 Share Posted February 14, 2007 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. Quote Link to comment Share on other sites More sharing options...
ayok Posted February 15, 2007 Author Share Posted February 15, 2007 Hi Greaser, I already solve the problem with the html email. To send the image, I just add it in the label of the text area. But now I have another issue.. I can't send the email to hotmail since I use the html email.... Quote Link to comment Share on other sites More sharing options...
redarrow Posted February 15, 2007 Share Posted February 15, 2007 <?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: server@barnyard.com\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"; ?> Quote Link to comment Share on other sites More sharing options...
ayok Posted February 15, 2007 Author Share Posted February 15, 2007 Thanks Redarrow, But I want the pic in the email. "print ("<img src='http://www.what_ever.com/image.gif'></img><br>" put my pic on the next page. And I still can't send to hotmail.. ayok Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.