Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

HTML Newsletter?


sefu

Recommended Posts

Posted

I seen some talk about a HTML newsletter. Has anyone managed to hack it to send newsletters in HTML. I have customers complaining about the current format.

 

If not can we use another newsletter script to use the OSC database?

Posted

you can use any script you want... all you need is one query that gets all the subscribers out of the db.

SELECT customers_email_address FROM customers WHERE customers_newsletter = 1

 

That will give you a list of all subscribers.

"Politics is the art of preventing people from taking part in affairs which properly concern them"

Posted

Cool thanks for your great help again Mattice,

Any good newsletter script that you recommend?

Posted

wouldn't know since I don't like html newsletters but your best bet will be www.hotscripts.com ...

"Politics is the art of preventing people from taking part in affairs which properly concern them"

Posted

Yeah just looking around now :D

 

there wouldnt be a simple hack for OSC to allow html newsletter would there? Be much easier then hacking the whole script of a new script

Posted

Yeah there is a simple hack.

 

I cant remember off hand how i did it but if you search back thru the old development forums you will find out how its done.

 

It was quite easy actually

Posted

Thanks Steve,

I think I found your post

http://www.oscommerce.com/forums/viewtopic.php...p?p=59262#59262

 

the last post on that page

 

So if i replace the newsletter code with the following it will work?

 

function send($newsletter_id) { 

$mail_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'"); 



// Instantiate a new mail object 

$mimemessage = new email(array('X-Mailer: osC mailer')); 



// Build the text version 

$text = strip_tags($text); 

if (EMAIL_USE_HTML == 'true') { 

$mimemessage->add_html($this->content); 

} else { 

$mimemessage->add_text($this->content); 

} 



// Send message 

$mimemessage->build_message(); 

while ($mail = tep_db_fetch_array($mail_query)) { 

$mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], '', EMAIL_FROM, $this->title); 

} 

$newsletter_id = tep_db_prepare_input($newsletter_id); 

tep_db_query("update " . TABLE_NEWSLETTERS . " set date_sent = now(), status = '1' where newsletters_id = '" . tep_db_input($newsletter_id) . "'"); 

} 

} 

?>

Posted

um yep i think that was all that had to be done.

 

I use it on my hosting site to send out newsletters in full html and it works well.

 

I just design up my page in FrontPage and copy the code across. (it displays a bit weird in the preview however, but sends ok).

 

The only thing i will say is that a function should be added to the signup page that allows the user to choose between html and standard emails.

 

Just make sure that you refer to the images you use with full http paths and remove any header info that your text editor may add.

 

Just make sure the header of the newsletter you design up has at least:

 

<html>



<head>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<title>ALPINE HOSTING August 2002 Newsletter</title>

</head>

 

remove any refernces to front page etc if you use that as Spam Assassin and other spam filters will send it to spam, or at least thats what ive found.

 

HTH

Posted

Thanks Steve,

You wouldnt remember where each bit of code goes do you? or are you will to share the newsletter.php file?

Posted

Just replace what you have in the newsletter.php file with whats above.

 

You will see where it goes. Its just a simple swap of code.

Posted

hang on my newsletter has no comments so I dont know where im looking :(

Posted

Ok heres the doe i have. Yours may be a bit different so backup backup backup

 

<?php

/*

 $Id: newsletter.php,v 1.1 2002/03/08 18:38:18 hpdl Exp $



 osCommerce, Open Source E-Commerce Solutions

 http://www.oscommerce.com



 Copyright (c) 2002 osCommerce



 Released under the GNU General Public License

*/



 class newsletter {

   var $show_choose_audience, $title, $content;



   function newsletter($title, $content) {

     $this->show_choose_audience = false;

     $this->title = $title;

     $this->content = $content;

   }



   function choose_audience() {

     return false;

   }



   function confirm() {

     global $HTTP_GET_VARS;



     $mail_query = tep_db_query("select count(*) as count from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'");

     $mail = tep_db_fetch_array($mail_query);



     $confirm_string = '<table border="0" cellspacing="0" cellpadding="2">' . "n" .

                       '  <tr>' . "n" .

                       '    <td class="main"><font color="#ff0000"><b>' . sprintf(TEXT_COUNT_CUSTOMERS, $mail['count']) . '</b></font></td>' . "n" .

                       '  </tr>' . "n" .

                       '  <tr>' . "n" .

                       '    <td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "n" .

                       '  </tr>' . "n" .

                       '  <tr>' . "n" .

                       '    <td class="main"><b>' . $this->title . '</b></td>' . "n" .

                       '  </tr>' . "n" .

                       '  <tr>' . "n" .

                       '    <td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "n" .

                       '  </tr>' . "n" .

                       '  <tr>' . "n" .

                       '    <td class="main"><tt>' . nl2br($this->content) . '</tt></td>' . "n" .

                       '  </tr>' . "n" .

                       '  <tr>' . "n" .

                       '    <td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "n" .

                       '  </tr>' . "n" .

                       '  <tr>' . "n" .

                       '    <td align="right"><a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID'] . '&action=confirm_send') . '">' . tep_image_button('button_send.gif', IMAGE_SEND) . '</a> <a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a></td>' . "n" .

                       '  </tr>' . "n" .

                       '</table>';



     return $confirm_string;

   }



   function send($newsletter_id) {

     $mail_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'");



   // Instantiate a new mail object

   $mimemessage = new email(array('X-Mailer: osC mailer'));



   // Build the text version

   $text = strip_tags($text);

   if (EMAIL_USE_HTML == 'true') {

     $mimemessage->add_html($this->content);

   } else {

     $mimemessage->add_text($this->content);

   }



   // Send message

   $mimemessage->build_message();

   while ($mail = tep_db_fetch_array($mail_query)) {

   $mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], '', EMAIL_FROM, $this->title);

 }

     $newsletter_id = tep_db_prepare_input($newsletter_id);

     tep_db_query("update " . TABLE_NEWSLETTERS . " set date_sent = now(), status = '1' where newsletters_id = '" . tep_db_input($newsletter_id) . "'");

   }

 }

?>

Posted

One more thing, how can I make it possible to just send to the owner. I want to test it out before I send in bulk

Posted

Um now theres the problem unfortunately

 

The easiest way would be to go into the sql and change the subscription value for each of your customers to 0 so that they arent subscribed.

 

Then register yourself as a subscribed user and send an email.

 

Once you know it works then you can change all your subscribed users back to "1"

Posted

I must be blind, I don't see it. Can anyone give me a ballpark line number to look for please?

 

I'd hate to screw my site up..but I asked this question in another thread last night (never saw this thread until today, sorry)

Posted

Catalog/admin/includes/modules/newsletter/newsletter.php

 

look for that file and change it there.

 

I'm still having troubles sending it in HTML, it just sends the rough code still. Is there something else I have to add elsewhere?

Posted

i didn't know about that option :?

Will give it a go. thanks for that

Posted

I've been having a problem with this. In Outlook Express as an example the raw html comes through.

 

I have copied the code from Snowman and created an html document but the newsletter is still in raw html, however, it does show up properly in Hotmail or other web-based e-mail system.

 

What could I be doing wrong?

Posted
I've been having a problem with this.  In Outlook Express as an example the raw html comes through.

 

I have copied the code from Snowman and created an html document but the newsletter is still in raw html, however, it does show up properly in Hotmail or other web-based e-mail system.

 

What could I be doing wrong?

 

You will need to set Use MIME HTML When Sending E-Mails in the email configurations in the Admin. I had the same prob

Archived

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

×
×
  • Create New...