Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Newsletter Unsubscribe v1.1


Recommended Posts

  • Replies 70
  • Created
  • Last Reply

Top Posters In This Topic

This has me puzzled. The variable is used to send the email, ao it has to be there or you wouldn't get the email at all. I'll go take another look at the code, and let you know if I find anything. Right now I'm stumped.

 

Regards

Jim

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

Link to comment
Share on other sites

Thanks in advance Jim!

Hope you can solve my problem.

I would also appreciate if other people help us/me ...

 

Could it have something to do with security?

Could someone give me a url to a shop with a working version of this contri?

Link to comment
Share on other sites

Just to clarify -- mine works just fine, but without the HTML contribution that you are using. The most obvious conclusion is that something in the HTML contrib is causing the problem.

 

Regards

Jim

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

Link to comment
Share on other sites

Thanks Jim,

 

Then somebody who's having a working version AND the HTML contri could solve my problem.

More people asked questions about using this contri toghether with the MAXIDVD WYSIWYG HTML contri. I supose at least one of them has got this working (?)

If so, please post the code!!

Link to comment
Share on other sites

OK, I see the problem now. My apologies for not catching this sooner. The variable $mail['customers_email_address'] is only set inside the while loop. You need to move most of your code inside the loop for this to work. My code looks 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'");
$mail['customers_lastname'], $mail['customers_email_address'], '', EMAIL_FROM, $this->title);
     // Begin Unsubscribe hack
       $mimemessage = new email(array('X-Mailer: osCommerce bulk mailer'));
       while ($mail = tep_db_fetch_array($mail_query)) {
         $mimemessage->add_text($this->content . TEXT_UNSUBSCRIBE . HTTP_CATALOG_SERVER . FILENAME_UNSUBSCRIBE . "?email=" . $mail['customers_email_address']);
         $mimemessage->build_message();
         $mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], '', EMAIL_FROM, $this->title);
       }
     // End Unsubscribe hack

 

This should work for you if you modify the $mimemessage->add_text() to add_html(). If you have any problems with this, please let me know.

 

Regards

Jim

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

Link to comment
Share on other sites

Jim, I'm grateful you're trying to help me with this.

This is the source with the Maxi DVD WYSIWYG contri

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

Because the ($this->content); part is between the modified code I supose that's the place to paste the code for the Unsubscibe contri (like I've tryed earlier). Problem is that the while loop comes later :o

 

How would you add this code to it?

// Begin Unsubscribe hack
       $mimemessage = new email(array('X-Mailer: osCommerce bulk mailer'));
       while ($mail = tep_db_fetch_array($mail_query)) {
          $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>');
 $mimemessage->build_message();
$mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], '', EMAIL_FROM, $this->title);
       }
// End Unsubscribe hack

Link to comment
Share on other sites

Try 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'));
    while ($mail = tep_db_fetch_array($mail_query)) {
// 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();
      $mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], '', EMAIL_FROM, $this->title);
    }

 

Regards

Jim

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

Link to comment
Share on other sites

Yes! With this code:

   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'));
   while ($mail = tep_db_fetch_array($mail_query)) {
// 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'] . '">' . HTTP_CATALOG_SERVER . DIR_WS_CATALOG . FILENAME_UNSUBSCRIBE . "?email=" . $mail['customers_email_address'] . '</a>');

     } else {
     $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>');

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

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

The link shows up with the e-mailaddress!!! :)

Thank you Jim!!!

 

But:

If I click the link in my mailmessage I'm getting the unsubscribe page.

So far so good...

There I push the unsubscribe button. Then I see a message that the mailaddress is not in the DB or already unsubscribed.

Below I see this mailaddress: me@myisp..nl

The mailaddress contains TWO dots :o

This is caused because the link I've clicked in my email looks like this in my browser:

http://www.mydomain.nl/webshop/catalog/[email protected]

(also 2 dots after myisp)

 

Strange because the link in the email is correct:

http://www.mydomain.nl/webshop/catalog/[email protected]

:blink: :(

Link to comment
Share on other sites

That's odd. If the link is correct in the email, it should transfer to the browser. Try looking at the source of the email (the raw HTML code.) If you see anything in that link that shouldn't be there, that would give us a hint of what to look for.

 

Regards

Jim

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

Link to comment
Share on other sites

Odd indeed. After sending a new newsletter I've received it on another testaccount with a correct link that works(!)

Finally I see this is working. :)

 

The first testaccount (the one that had the dubble dot) isn't reveiving newsletter anymore.

In the admin the option to receive the the newsletter is set to receive.

Strange :blink:

 

Sending a normal mail from the admin to testaccount 1 works...

 

The source from the mail to acount 1 was:

<a href="http://www.mydomain.nl/webshop/catalog/[email protected]">http://www.mydomain.nl/webshop/catalog/[email protected]</a>

The visual part of the link is correct but the source part contains the dubble dot in the mailaddress.

 

What more to do to check why account 1 isn't receiving the newsletters anymore?

Link to comment
Share on other sites

Odd indeed. Perhaps the database has somehow been corrupted. You could look at the customer information directly in the database. Otherwise, I would just delete the first account, then create a new one with the same email address. If the problem goes away, then we know that something was messed up in that account.

 

Regards

Jim

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

Link to comment
Share on other sites

Hi Jim,

 

I'm happy to let you know that I received (after a 3,5 hour delay) the newsletter to account 1!! :)

The link is correct and works!

I think everything is OK now.

I did a full database optimize, but if it had anything to do with it...

No idea how/why the double dot bug appeared :huh:

Hope it was a one time bug (?)

 

I'm very happy with this contribution!

 

Jim, many thanks for helping me :thumbsup:

Link to comment
Share on other sites

  • 3 weeks later...
OK, I see the problem now. My apologies for not catching this sooner. The variable $mail['customers_email_address'] is only set inside the while loop. You need to move most of your code inside the loop for this to work. My code looks 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'");
$mail['customers_lastname'], $mail['customers_email_address'], '', EMAIL_FROM, $this->title);
? ? ?// Begin Unsubscribe hack
? ? ? ?$mimemessage = new email(array('X-Mailer: osCommerce bulk mailer'));
? ? ? ?while ($mail = tep_db_fetch_array($mail_query)) {
? ? ? ? ?$mimemessage->add_text($this->content . TEXT_UNSUBSCRIBE . HTTP_CATALOG_SERVER . FILENAME_UNSUBSCRIBE . "?email=" . $mail['customers_email_address']);
? ? ? ? ?$mimemessage->build_message();
? ? ? ? ?$mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], '', EMAIL_FROM, $this->title);
? ? ? ?}
? ? ?// End Unsubscribe hack

 

This should work for you if you modify the $mimemessage->add_text() to add_html(). If you have any problems with this, please let me know.

 

Regards

Jim

Hi Jim,

 

I have been reading your posts and as you seem good at this I wonder if you could help me with this:

 

I had installed the newsletter and subscribers 0.48 which was highly unstable. (only realise this now).

 

Only now I understand something is wrong with the unsubscribe link. It goes to the unsubscribe page and people can see the button but NOT the Box. This is somehow disturbing because I would like people to remove their email buy entering it there if they receive a newsletter not sent thru Osc.

 

Could you please tell me what I did wrong I have been replacing the files but still the box doesn't appears.

 

Also A problem that has occured is that customers get a blank email from the 'order update' . Which file is corrupted? I can't figure this out but I am sure it is due to the newsletter module.

 

Sorry for the bad english.

Any help would be greatly appreciated.

Link to comment
Share on other sites

Hi Yandus

 

I'm not familiar with the Subscriber contribution, so I'm not going to be much help with that part. If it truly has a version of 0.48, that would indicate that it is Beta code and should never be used on a production site.

 

The only things that I can suggest are:

1. Check the installation instructions carefully to make sure you have not left anything out or put new code in the wrong place.

2. If everything looks right, go back to your unmodified code and see if the problems stop. If they do, you at least know what is causing it.

 

Regards

Jim

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

Link to comment
Share on other sites

Hi Yandus

 

I'm not familiar with the Subscriber contribution, so I'm not going to be much help with that part. If it truly has a version of 0.48, that would indicate that it is Beta code and should never be used on a production site.

 

The only things that I can suggest are:

1. Check the installation instructions carefully to make sure you have not left anything out or put new code in the wrong place.

2. If everything looks right, go back to your unmodified code and see if the problems stop. If they do, you at least know what is causing it.

 

Regards

Jim

Hello Jim,

 

Thanks for your wise words. I am somehow new to osc but to be honest I like it. I am going thru all the post about newsletters so I hope to find a solution to my problem. If you know which file in admin is responsible for sending 'blank' order updates to customers it would be of a great help to me. (for 3 days now I am searching the solution)

 

 

When using the code below I have prices as 3.00 instead of 3.99

Do you see the fault? The Kelkoo thread is dead!

 

// Prix du produit (price)
 if ($new_price = tep_get_products_special_price($products['products_id'])) {
   $kelkoo_list .= number_format((tep_round($new_price, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places'])) + (tep_calculate_tax($new_price, tep_get_tax_rate($products['products_tax_class_id']))), 2, '.', '') . "\t";
 } else {
   $kelkoo_list .= number_format((tep_round($products['products_price'], $currencies->currencies[DEFAULT_CURRENCY]['decimal_places'])) + (tep_calculate_tax($products['products_price'], tep_get_tax_rate($products['products_tax_class_id']))) , 2, '.', '') . "\t";
 }

 

By the way I am going to install the newsletter unsubscribe (latest version) Maybe that will help!

Link to comment
Share on other sites

  • 4 years later...

I can not get this to work. Please help.

 

After sending a newsletter, and clicking on the link to unsubscribe, I get an error: 404 - This page can not be found. I cant figure out what is wrong.

 

At the top of the error page, the url looks like this: https://site.com/[email protected].

 

I have checked and double checked the install files. Everything is done per the install instructions. It's like its not finding that file. But if I go into my site files, and click on the unsubscribe.php file, it does pull up the unsubscribe page.

 

Please help. I think its in the admin/modules/newsletters/newsletter.php file but not sure.

 

I have rc2a

 

Thank you for your help.

Link to comment
Share on other sites

I can not get this to work. Please help.

 

After sending a newsletter, and clicking on the link to unsubscribe, I get an error: 404 - This page can not be found. I cant figure out what is wrong.

 

At the top of the error page, the url looks like this: https://site.com/[email protected].

 

I have checked and double checked the install files. Everything is done per the install instructions. It's like its not finding that file. But if I go into my site files, and click on the unsubscribe.php file, it does pull up the unsubscribe page.

 

Please help. I think its in the admin/modules/newsletters/newsletter.php file but not sure.

 

I have rc2a

 

Thank you for your help.

 

 

I reinstalled it yet another time, and it works!!!!

Link to comment
Share on other sites

  • 3 weeks later...

Hello,

 

since a month I am using the automated unsubscribe contribution. Since then, my HTML traffic has increased a lot (I noticed this as I went over my 10GB/month limit from my provider).

First: newsletter received = 50KB --> not much extra traffic when sending the newsletter compared to a normal day:: 100/200MB to +-250 customers

Now: newsletter received = 50KB --> traffic = 3GB, to +-700 customers (I added all the physical shop customers).

 

I think it has to do that the $mimemessage->add_html($this->html_content() is inside the SEND loop?

But, at the same time, this is strange as everything is handled on the server (no?), so this should not add up to my HTML traffic?

 

Actual send loop with contribution:

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: osCommerce bulk mailer'));
	//$mimemessage->add_html($this->html_content());

  // Send message
	//$mimemessage->build_message();
  while ($mail = tep_db_fetch_array($mail_query)) {
	$mimemessage->add_html($this->html_content() . 

	'<table align="center" border="0" cellpadding="7" cellspacing="0" width="635">
	<tbody>
	  <tr>
		 <td align="center">
		 <p style="font-size: 60%; font-family: Verdana,sans-serif; color: rgb(0, 0, 0);"><span style="font-weight: bold;">' .		

	TEXT_UNSUBSCRIBE . '<a href="' . HTTP_CATALOG_SERVER . DIR_WS_CATALOG . FILENAME_UNSUBSCRIBE . "?email=" . $mail['customers_email_address'] . '"> Uitschrijven </a>

		 </p>
		 </td>
	  </tr>
	</tbody>
  </table>');		

	$mimemessage->build_message();
	$mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], 'Gobelix Strips', '[email protected]', 'nieuwsbrief - [' . $this->newsletter_date . ']');
  }

 

Previous SEND loop (without contribution):

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

  // Instantiate a new mail object
  $mimemessage = new email(array('X-Mailer: osCommerce bulk mailer'));
  $mimemessage->add_html($this->html_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'], 'Gobelix Strips', '[email protected]', 'nieuwsbrief - [' . $this->newsletter_date . ']');
  }

 

Anyone any clue?

 

Thanks in advance,

 

Xinirnix

Edited by xinirnix
Link to comment
Share on other sites

  • 2 weeks later...

I am trying to get this to work with products newsletter and products notifications.

 

Does anyone have the code change in admin/includes/modules/newsletters/product_notifications.php and admin/includes/modules/newsletters/newsletter_products.php

 

product_notifications.php original code

	  $mimemessage = new email(array('X-Mailer: osCommerce bulk mailer'));
  $mimemessage->add_text($this->content);
  $mimemessage->build_message();

  reset($audience);
  while (list($key, $value) = each ($audience)) {
	$mimemessage->send($value['firstname'] . ' ' . $value['lastname'], $value['email_address'], '', EMAIL_FROM, $this->title);
  }

 

newsletter_products.php original code

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

  //$mimemessage->add_text($this->content);
  //$text = $this->text_content();

  $mimemessage->add_html($this->html_content(), $this->text_content(), HTTP_CATALOG_SERVER . DIR_WS_CATALOG_IMAGES);
  $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);
  }

 

Thanks for any help you can give.

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...