Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Newsletter Unsubscribe v1.1


Recommended Posts

kymation,

before I go into the trouble of trying out your release, I think it would benefit everyone if you were to please list all the changes you've made. many of the directories in your release are empty, and I don't know If that's deliberate or not.

 

Have you found a fix for the problem I had - the contribution passed the sID as part of the email address, and returned an error with every unsubscribe atempt.

 

-Ethan

Link to comment
Share on other sites

  • Replies 70
  • Created
  • Last Reply

Top Posters In This Topic

The empty directories are just a result of getting the language file in the right place. They are "empty" because there are no files in those directories that are relevant to this contribution.

 

Yes, this should fix the problem that you noticed. If you have already installed the previous version, just drop in the unsubscribe.php and unsubscribe_done.php and your mod should work.

 

If you really want the changes:

  • In unsubscribe.php, modified the call to tep_href_link to properly pass the email address when SIDs are in use.
  • In unsubscribe.php and unsubscribe_done.php, added checking of the input data to prevent hacking via SQL injection.
  • In the readme, updated instructions to put the defines for filenames in includes/filenames.php, and added the define for unsubscribe_done.php.

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Jim,

Your contibution worked, thank you!

I did, however, have to make a few changes, which I beleive should be made public as the next version:

1. in order for the link in the email to work, you must add the following lines to admin/includes/filenames.php:

//// Begin Unsubscribe hack
? define('FILENAME_UNSUBSCRIBE', 'unsubscribe.php');
//// End Unsubscribe hack

 

2. sdtep 2 of the readme creates a link which is missing the /catalog/ part of the URL. to fix this, replace

$mimemessage->add_text($this->content . TEXT_UNSUBSCRIBE . HTTP_CATALOG_SERVER . FILENAME_UNSUBSCRIBE . "?email=" . $mail['customers_email_address']);

with

$mimemessage->add_text($this->content . TEXT_UNSUBSCRIBE . HTTP_CATALOG_SERVER . DIR_WS_CATALOG . FILENAME_UNSUBSCRIBE . "?email=" . $mail['customers_email_address']);

Also, if you're sending out HTML base emails, as I am, you may want to change the function call from add_text to add_html. In order to make the link clickable in an HTML email, as well as in non-HTML email clients, replace

$mimemessage->add_text($this->content . TEXT_UNSUBSCRIBE . HTTP_CATALOG_SERVER . DIR_WS_CATALOG . FILENAME_UNSUBSCRIBE . "?email=" . $mail['customers_email_address']);

with

$mimemessage->add_html($this->content . TEXT_UNSUBSCRIBE . '<a href="' . HTTP_CATALOG_SERVER . DIR_WS_CATALOG . FILENAME_UNSUBSCRIBE . "?email=" . $mail['customers_email_address'] . '">' . HTTP_CATALOG_SERVER . DIR_WS_CATALOG . FILENAME_UNSUBSCRIBE . "?email=" . $mail['customers_email_address'] . '</a>');

 

3. again in the readme, you left the line that advises on how to check if it works with the mistake it had in it. that is, it says

? ? UPDATE customers SET customer_newsletter = '2' where customer_newsletter = '1'

instead of

? ? UPDATE customers SET customers_newsletter = '2' where customers_newsletter = '1'

other then that (and those are really minor fixes), It works like a charm! I think a new version ought to be made with the fixes I proposed. If you prefer, I'll make it.

 

-Ethan

Edited by Ethan1701
Link to comment
Share on other sites

Thanks for the update. You seem to have caught all of the things that I forgot to mention. Please do put this up as an update to the contribution, as I'm sure that others will need it as well.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

this mode fails on my install when using search engine safe urls. When the url is transferred from unsubscribe.php to unsubscribe_done.php the url changes from [email protected] into something like email/[email protected] and the database query fails as a result. As a work around, I have the link point straight to unsubscribe_done.php, but are there any thoughts on how to get this to work regular?

Link to comment
Share on other sites

Ed, I could never get the search engine safe URLs to work. it would do what you described to every parameter it would pass...

 

I don't know how it's meant to work, but it shouldn't be to hard to fix this..

 

-Ethan

Link to comment
Share on other sites

Wow, you guys sure took this a long way, lol.

 

Sorry I havn't had time to continue to support it, but it seems that Jim and Ed have picked up my slack considerably.

 

Thankd guys.

-------------------------------------------------------------------------------------------------------------------------

NOTE: As of Oct 2006, I'm not as active in this forum as I used to be, but I still work with osC quite a bit.

If you have a question about any of my posts here, your best bet is to contact me though either Email or PM in my profile, and I'll be happy to help.

Link to comment
Share on other sites

THat's the beauty of open source (or Free software, as you like). leave the code lieing around, and someone else is bound to use it and make something even better out of it!

 

Glad to have helped.

 

-Ethan (who the fog is Ed?)

Link to comment
Share on other sites

Opps.

 

Ethan, I mean. Sorry about that.

-------------------------------------------------------------------------------------------------------------------------

NOTE: As of Oct 2006, I'm not as active in this forum as I used to be, but I still work with osC quite a bit.

If you have a question about any of my posts here, your best bet is to contact me though either Email or PM in my profile, and I'll be happy to help.

Link to comment
Share on other sites

  • 2 months later...
Ed, I could never get the search engine safe URLs to work. it would do what you described to every parameter it would pass...

 

I don't know how it's meant to work, but it shouldn't be to hard to fix this..

 

-Ethan

If you're still needing a fix for this, I have a workaround available.

Link to comment
Share on other sites

  • 2 weeks later...

Hi!

 

I'm going to intall this mod on my site but my admin/includes/modules/newsletters/newsletter.php page is different cos I have installed WYSIWYG HTMLArea MS2 v1.7 contribution.

 

I dont know how to implement the code changes described in the 2nd installation step.

 

I would like to ask somebody to post back this code with the necessary extra code without losing the WYSIWYG feature.

 

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

      // MaxiDVD Added Line For WYSIWYG HTML Area: BOF (Send TEXT Newsletter v1.7 when WYSIWYG Disabled)

      if (HTML_AREA_WYSIWYG_DISABLE_NEWSLETTER == 'Disable') {

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

      } else {

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

// MaxiDVD Added Line For WYSIWYG HTML Area: EOF (Send HTML Newsletter v1.7 when WYSIWYG Enabled)

      }

      $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);

      }

 

 

Thx in advance,

Andrew

Link to comment
Share on other sites

  • 2 weeks later...
  • 4 months later...

I'm also using the WYSIWYG HTMLArea MS2 v1.7 contribution.

Would anybody be so kind to give the code to implement this nice unsubscribe contri together with WYSIWYG please?

 

If I use it like this:

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

     $mimemessage = new email(array('X-Mailer: osCommerce bulk mailer'));
// MaxiDVD Added Line For WYSIWYG HTML Area: BOF (Send TEXT Newsletter v1.7 when WYSIWYG Disabled)
     if (HTML_AREA_WYSIWYG_DISABLE_NEWSLETTER == 'Disable') {
     $mimemessage->add_text($this->content . TEXT_UNSUBSCRIBE . '<a href="' . HTTP_CATALOG_SERVER . DIR_WS_CATALOG . FILENAME_UNSUBSCRIBE . "?email=" . $mail['customers_email_address'] . '">here</a>');
     } else {
     $mimemessage->add_html($this->content . TEXT_UNSUBSCRIBE . '<a href="' . HTTP_CATALOG_SERVER . DIR_WS_CATALOG . FILENAME_UNSUBSCRIBE . "?email=" . $mail['customers_email_address'] . '">here</a>');
// MaxiDVD Added Line For WYSIWYG HTML Area: EOF (Send HTML Newsletter v1.7 when WYSIWYG Enabled)
     }

     $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) . "'");
   }
 }
?>

there's no e-mailadres attached to the link :'(

Link to comment
Share on other sites

I'm not using the WYSIWYG contribution, so I can't give you any easy fixes. However, something about this is bothering me. Are you actually getting the link in the email, just without the email address? If so, check your code. The variable $mail['customers_email_address'] must be present for this to work, so it should be inserted if the email is working at all.

 

If I have misunderstood, could you post the last part of an email (the part with this link?) I'd like to see what's actually going out.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Thanks for the reply.

The link shows up in the newsletter but because the e-mailadress is missing it doesn't work. If I click the link I'm going to the url: http://www.mydomain.nl/webshop/catalog/uns...ribe.php?email=

 

As you can see in my code posted earlier I've used the variable "?email=" . $mail['customers_email_address'] . '">here</a>');

 

But somehow it's not working, something wrong in the coding line?

Link to comment
Share on other sites

Very odd. I don't see anything wrong with your code. The only thing that I can see is that this link will be at the end of the HTML block, after the closing tags. If this has any effect, it should make the entire link disappear or malfunction, not just take the variable away.

 

Try adding the variable into the message earlier, like this:

      } else {
    $mimemessage->add_html($this->content . $mail['customers_email_address'] . 'TEXT_UNSUBSCRIBE . '<a href="' . HTTP_CATALOG_SERVER . DIR_WS_CATALOG . FILENAME_UNSUBSCRIBE . "?email=" . $mail['customers_email_address'] . '">here</a>');
// MaxiDVD Added Line For WYSIWYG HTML Area: EOF (Send HTML Newsletter v1.7 when WYSIWYG Enabled)

Then send a test message. The email address should show up just before the unsubscribe message. If it doesn't, we know something is going wrong with this variable.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

It gives an error in my Admin:

Parse error: parse error in c:\domains\mydomain.nl\wwwroot\webshop\catalog\admin\includes\modules\newsletters\newsletter.php on line 67

 

Line 67 is (your modified line):

    $mimemessage->add_html($this->content . $mail['customers_email_address'] . 'TEXT_UNSUBSCRIBE . '<a href="' . HTTP_CATALOG_SERVER . DIR_WS_CATALOG . FILENAME_UNSUBSCRIBE . "?email=" . $mail['customers_email_address'] . '">here</a>');

Link to comment
Share on other sites

There is a typo in the code. Without errors introduced by my fat fingers, it should be:

     $mimemessage->add_html($this->content . $mail['customers_email_address'] . TEXT_UNSUBSCRIBE . '<a href="' . HTTP_CATALOG_SERVER . DIR_WS_CATALOG . FILENAME_UNSUBSCRIBE . "?email=" . $mail['customers_email_address'] . '">here</a>');

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...