Jump to content
scottyb

Newsletter products, HTML email

Recommended Posts

Hi patamu,

 

to change the size of your pictures in your newsletter , just change into the module/newsletter/newsletter_product.php

the osc function tep_image

 

tep_image(HTTP_CATALOG_SERVER . DIR_WS_CATALOG_IMAGES . $this->productsInfo[$i]['products_image'], $this->productsInfo[$i]['products_name'], $imgWidth, $imgHeight)

 

Right, sort of fixed it...

 

If I change the variables $imgWidth, $imgHeight for specific numbers and it works fine.

So I've set them to a size I'm happy with which will do for the time being.. :)

 

Now to sort out the template!

 

Mat

Share this post


Link to post
Share on other sites

Hi,

 

I saw something about this error earlier in the thread but it wasnt too specific on how to fix the problem:

 

1146 - Table 'independentoffers_ie.table_newsletters_to_products' doesn't exist

select products_id from TABLE_NEWSLETTERS_TO_PRODUCTS where newsletters_id = '4'

[TEP STOP]

 

I tried making sure the define was added to database_tables.php but still that error pops up... any ideas? From ms2.2 on, is there another file other than database_tables.php that needs the db tables defined in it as well?

 

Thanks.

Share this post


Link to post
Share on other sites
Hi,

 

I saw something about this error earlier in the thread but it wasnt too specific on how to fix the problem:

 

1146 - Table 'independentoffers_ie.table_newsletters_to_products' doesn't exist

select products_id from TABLE_NEWSLETTERS_TO_PRODUCTS where newsletters_id = '4'

[TEP STOP]

 

I tried making sure the define was added to database_tables.php but still that error pops up... any ideas? From ms2.2 on, is there another file other than database_tables.php that needs the db tables defined in it as well?

 

Thanks.

 

Got it to work by putting the define in application_top.php...

 

Having problems trying to get it to work with MaxiDVD images mod, how would i get it to rip the imagecache images instead of the original images?

 

Also, the links being generated on the images are linking to my admin site instead of the catalog site, how would i change that?

 

Thanks, great mod!

Share this post


Link to post
Share on other sites
thank you for the reply

 

   $image_new = "images/logo.jpg";
copy($image,$image_new); 
$attachment = fread(fopen($image_new, "r"), filesize($image_new));
$mail->add_attachment("$attachment", $image_new, "image/jpeg");
$mail->send();
@unlink($iamge_new);

 

i am looking for something like the above code,

but it adds the images as a attachment... but to stop the message about unsecure blocked items in mail it needs to be embedded like if you insert images in outlook...

 

did not work for me ;(

 

MR-M

 

 

Well, It worked marvelously for me...

 

I'm designing a Shop for handelds/cellular phones.

So a customer can buy a handheld with or without a contract.

IF the customer chooses a contract then he receives the contract formular(s) as pdf in his confirmation email... so the following things ive altered:

 

/catalog/checkout_process.php

 

go to ->

// lets start with the email confirmation

 

1st I had to create a function to check IF there's been a contract chosen within the shopping cart:

 

$antrag_count = 0;

$send_antrag_array = array();

 

aprox at line 224, beneath this code line:

		} else {
	  $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix

within the else { } brackets I've inserted:

 

if($order->products[$i]['attributes'][$j]['option_id'] == '40' && $order->products[$i]['attributes'][$j]['value_id'] != 160) {

$send_antrag_array[$antrag_count] = $order->products[$i]['attributes'][$j]['value_id'];

$antrag_count++;

}

 

In this case option_id = '40' is the ID for that attribute (Simlock contract)

and value_id != 160 is the ID for the value of the attribute (160 is 'without contract' and all others therefore are with a contract)

 

later on ive added this code where the email text gets generated:

	if(count($send_antrag_array) >0) { 
	  ...
		 for($i=0; $i<=count($send_antrag_array)-1; $i++) {
			 ... extract pdf url path and name via SQL queries...
	array_push($pdf_url_array, $antrag_pdf_result['antrag_pdf_url']);
	array_push($pdf_name_array, $antrag_name_result['products_options_values_name']);
		 }
	  ...
	 }
...

if(count($pdf_url_array)>0) {  // if there are pdf urls within that array send to MODIFIED function
  tep_mail_attachment($order->customer['firstname'] . ' ' . $order->customer['lastname'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, $pdf_url_array, $pdf_name_array);
 }
 else { //send to ORIGINAL function
  tep_mail($order->customer['firstname'] . ' ' . $order->customer['lastname'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
 }

 

Now within /includes/function/general.php copy the tep_mail function, rename it to tep_mail_attachment and alter it accordingly:

 

////
//! Send email WITH the required Tarif-PDFs (text/html) using MIME in the order confirmation mail
// This is the central mail function. The SMTP Server should be configured
// correct in php.ini
// Parameters:
// $to_name		   The name of the recipient, e.g. "Jan Wildeboer"
// $to_email_address  The eMail address of the recipient,
//					e.g. jan.wildeboer@gmx.de
// $email_subject	 The subject of the eMail
// $email_text		The text of the eMail, may contain HTML entities
// $from_email_name   The name of the sender, e.g. Shop Administration
// $from_email_adress The eMail address of the sender,
//					e.g. info@mytepshop.com
// $pdf_url			  ADDED : The array with the urls to the desired PDFs
// $pdf_name		  ADDED : The array with the names of the desired PDFs

 function tep_mail_attachment($to_name, $to_email_address, $email_subject, $email_text, $from_email_name, $from_email_address, $pdf_url, $pdf_name) {
if (SEND_EMAILS != 'true') return false;

// Instantiate a new mail object
$message = new email(array('X-Mailer: osCommerce Mailer'));

// Build the text version
$text = strip_tags($email_text);
if (EMAIL_USE_HTML == 'true') {
  $message->add_html($email_text, $text);
} else {
  $message->add_text($text);
}
// ALTERED NEW CODE FOR ADDING ATTACHMENTS:
if(count($pdf_url)>0) { //Errorhandling : Only execute IF there's been URL transmitted
	for($i=0; $i<=count($pdf_url)-1; $i++) {
		//Errorhandling : IF /catalog/ is within the url string, remove it, and add it afterwards (to ensure consistency)
		if(stristr($pdf_url[$i], 'catalog/')) $explode_pdf_url_string = explode("catalog/", $pdf_url[$i]);
		else $explode_pdf_url_string[1] = $pdf_url[$i];
		$pdf_file = DIR_FS_CATALOG.$explode_pdf_url_string[1]; //set absollute path to the file using the global DIR_FS_CATALOG variable
		if(file_exists($pdf_file)) { //Errorhandling : Only execute IF the file really exists
			$attachment = fread(fopen($pdf_file, "r"), filesize($pdf_file));
			$message->add_attachment("$attachment", $pdf_name[$i], "application/pdf"); // ('file', 'name of file', 'content type')
		}
	}
}
// Send message
$message->build_message();
$message->send($to_name, $to_email_address, $from_email_name, $from_email_address, $email_subject);
 }

 

 

Notice that the url of the pdf and the name of the contract have been transmitted to the function (as array)

It works great for me!

Share this post


Link to post
Share on other sites
Got it to work by putting the define in application_top.php...

 

Having problems trying to get it to work with MaxiDVD images mod, how would i get it to rip the imagecache images instead of the original images?

 

Also, the links being generated on the images are linking to my admin site instead of the catalog site, how would i change that?

 

Thanks, great mod!

 

Hi all, with regard to the wrong link being produced and the wrong images being displayed, this bit of code seems to be responsible for controlling those two things, lines 152 and 153 from admin/includes.modules/newsletters/newsletter_products.php:

 

<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $this->productsInfo[$i]['products_id']) . '" style="' . $cssLink . '">' . tep_image(HTTP_CATALOG_SERVER_EMAIL . DIR_WS_CATALOG_IMAGES_EMAIL . $this->productsInfo[$i]['products_image'], $this->productsInfo[$i]['products_name'], 150) . '<br>' . $this->productsInfo[$i]['products_name'] . '</a>

 

The link that gets generated is one that points to the admin site instead of the catalog which must be caused by tep_href_link so i'd like to be able to substitute that link with a new define in configure.php which points to my catalog site, its called HTTP_CATALOG_SERVER_EMAIL. How would i rewrite the above bit of code to use this variable instead of tep_href_link ?

 

Also, with regard to the images, how would i get it to pull the MaxiDVD imagecache thumbnail images instead of the BIG images which get scaled down the old oscommerce way?

 

Thanks for any help...

Share this post


Link to post
Share on other sites

Another problem im facing with this mod is editing the text content and title of a newsletter. When ive already entered the title and text content of a newletter and hit save, everything seems fine. But when i try to edit the newsletter again, the title is blank and the text content is blank so that ive to enter it in all over again, why is it not retrieving the info i entered in already?

 

Thanks.

Share this post


Link to post
Share on other sites

Hi,

Just installed version 2.3. Everything seems to be working fine, creating a newsletter, previewing it etc.. but when I try to send it, this is what I get:

 

========

Warning: reset() [function.reset]: Passed variable is not an array or object in /home4/vyxncleu/public_html/admin/includes/classes/object_info.php on line 17

 

Warning: Variable passed to each() is not an array or object in /home4/vyxncleu/public_html/admin/includes/classes/object_info.php on line 18

 

Warning: main(includes/languages/polish/modules/newsletters/.php) [function.main]: failed to open stream: No such file or directory in /home4/vyxncleu/public_html/admin/newsletters.php on line 398

 

Warning: main(includes/languages/polish/modules/newsletters/.php) [function.main]: failed to open stream: No such file or directory in /home4/vyxncleu/public_html/admin/newsletters.php on line 398

 

Warning: main(includes/languages/polish/modules/newsletters/.php) [function.main]: failed to open stream: No such file or directory in /home4/vyxncleu/public_html/admin/newsletters.php on line 398

 

Warning: main() [function.include]: Failed opening 'includes/languages/polish/modules/newsletters/.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home4/vyxncleu/public_html/admin/newsletters.php on line 398

 

Warning: main(includes/modules/newsletters/.php) [function.main]: failed to open stream: No such file or directory in /home4/vyxncleu/public_html/admin/newsletters.php on line 399

 

Warning: main(includes/modules/newsletters/.php) [function.main]: failed to open stream: No such file or directory in /home4/vyxncleu/public_html/admin/newsletters.php on line 399

 

Warning: main(includes/modules/newsletters/.php) [function.main]: failed to open stream: No such file or directory in /home4/vyxncleu/public_html/admin/newsletters.php on line 399

 

Warning: main() [function.include]: Failed opening 'includes/modules/newsletters/.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home4/vyxncleu/public_html/admin/newsletters.php on line 399

 

Fatal error: Cannot instantiate non-existent class: in /home4/vyxncleu/public_html/admin/newsletters.php on line 405

 

================

 

Please advise what to do. Thanks -- ania

Share this post


Link to post
Share on other sites

Ok so just installed this much needed contrib. THANKS!!!!

So everything works, preview and all and looks good. But when I send it stays on the

 

Please wait .. sending emails ..

 

Please do not interrupt this process!

 

It is not sending the e-mails? Is there something I need to check with my hosting company?

 

Thanks in advance

Share this post


Link to post
Share on other sites

Hi there,

 

I've installed version 2.3 and everything is working fine except that it doesn't make my images smaller by using SMALL_IMAGE_WIDTH and SMALL_IMAGE_HEIGHT. In the Admin I've configured the SMALL_IMAGE_WIDTH to '100' and SMALL_IMAGE_HEIGHT to nothing. In the catalog on product_info.php for example the image is perfectly resizing. The width stays at 100 pixels and it's calculating itself how much the height must be.

 

But newsletter_products.php doens't work like that it seems. It's showing the original size of the images and because my original images are mostley 400 to 600 pixels wide, I got a use email sent to my customers.

 

I can't set the image width and height to a standard size because the pictures of my products do have different sizes. So when I set the width and height to say 100 and 200pixels, the images won't be in their proportions anymore.

 

Can anyone tell me how to fix this problem?

 

Kind regards,

 

Marcus

Share this post


Link to post
Share on other sites

Hello

 

I got a problem, the problem is that I got this fail everytime in admin: Error: Newsletter module required

 

I have choose Newsletter_produckts and I got this fail someone who know what this is?

 

Thanks for any help:)

Share this post


Link to post
Share on other sites

Hi. I installed the contribution 2.3 but I cannot see anything in admin section. I checked it many times but I can't find what I forget. What am I doing wrong?

 

I found it....I wasn't looking to the right place!!!!

Edited by mkam

Share this post


Link to post
Share on other sites

htacces protects the newsletter from being read by my customers, due to the fact that my admin section is pasword protected with a htacces.

This means that my customers won't see any newsletter until they have the right pasword!!

Probably because the template is in the admin section...............

 

Anyone ideas to solve this???

Thanks

Edited by abdllatif

Share this post


Link to post
Share on other sites
htacces protects the newsletter from being read by my customers, due to the fact that my admin section is pasword protected with a htacces.

This means that my customers won't see any newsletter until they have the right pasword!!

Probably because the template is in the admin section...............

 

Anyone ideas to solve this???

Thanks

The problem has been solved, you don't put the image files in the same folder as the template, since the admin section is most of the time htacces protected! If you put the imagefiles of your new template in the folder .../catalog/images there is no prolem at all.

Nice contribution, thank you.................!!

Share this post


Link to post
Share on other sites

Everything seems to be working here now since i changed the links generated and added new catalog links to configure.php especially for the newsletter mod (i'd say this only affects shared SSL accounts).

 

Some additions to this mod that i would love to see (as would many others im sure):

 

1. It would be excellent to be able to select which customers you want to send the newsletter to instead of the current "send to all customers or none" option. This way, you could tailor make newsletters based on a customers needs and send them instant info on certain products they are looking for. This would save many people the hassle of emailing certain product info to individual customers and having to copy/paste info and images into an email. This is a BIG deal for a lot of companies ive done osC sites for and having this option in the newsletter mod would be a huge time saver...

The only way around this currently is to preview a newsletter, view the source code and copy everything between <HTML> </HTML> and past this into Outlook Express to send from there, which works really well but its too fiddly for the average client...

 

2. Having the ability to add a certan amount of the product description to each product in the newsletter. This is one option that should have been there from the start! How many newsletters do you see from companies that just have the image, product name and price? None... They all have descriptions as well. This seems to be a fairly important feature to have on any newsletter mod.

 

Other than those two things, this is such an excellent mod, its the one mod ive come across that most companies are interested in getting! Thanks to the developers for this one! :)

Edited by sonictrip.net

Share this post


Link to post
Share on other sites

Oh man, dunno what im doing wrong on this site... I've installed this mod on 2 other sites and got them to work but im trying to install on another site and everything seems fine except the preview just shows a blank page?? What could be causing this? If i even just knew where to look i might be able to figure it out... thanks!

Share this post


Link to post
Share on other sites

Forget about the last post, i remembered i had modified html_output with a new tep_email_href_link function to accomodate my path names to my Catalog folder and for MaxiDVD coz on a shared server it didnt seem to be working too well and using Admin links instead; it would show everything fine except with the product name appearing twice on top of each other and no product image.

 

I modified admin/includes/functions/html_output and added the following above the HTML image wrapper function:

 

//newsletter mod for CATALOG link instead of ADMIN link:
 function tep_email_href_link($page = '', $parameters = '', $connection = 'NONSSL') {
if ($connection == 'NONSSL') {
  $link = HTTP_CATALOG_SERVER_EMAIL;

} else {
  die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine connection method on a link!<br><br>Known methods: NONSSL SSL<br><br>Function used:<br><br>tep_href_link(\'' . $page . '\', \'' . $parameters . '\', \'' . $connection . '\')</b>');
}
if ($parameters == '') {
  $link .= $page;
} else {
  $link .= $page . '?' . $parameters;
}

while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1);

return $link;
 }
////

 

 

Then i added the following two lines to admin/includes/configure.php:

 

 

define('HTTP_CATALOG_SERVER_EMAIL', 'http://www.website.ie/catalog/');
define('DIR_WS_CATALOG_IMAGES_EMAIL', 'images/');

 

 

Then i replaced this bit of code in admin/includes/modules/newsletters/newsletter_products.php:

 

 

$html_content .= '</tr><tr><td align="center" width="' . $width . '%"><a href="' . tep_catalog_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $this->productsInfo[$i]['products_id']) . '" style="' . $cssLink . '">' . tep_image(HTTP_CATALOG_SERVER . DIR_WS_CATALOG_IMAGES . $this->productsInfo[$i]['products_image'], $this->productsInfo[$i]['products_name']) . '<br>' . $this->productsInfo[$i]['products_name'] . '</a><br>';
			$price = ($this->productsInfo[$i]['specials_price']) ? '<span style="'. $cssMarkdown . '">' . $currencies->display_price($this->productsInfo[$i]['products_price'], tep_get_tax_rate($this->productsInfo[$i]['products_tax_class_id'])) . '</span>  <span style="' . $cssSale . '">' . $currencies->display_price($this->productsInfo[$i]['specials_price'], tep_get_tax_rate($this->productsInfo[$i]['products_tax_class_id'])) . '</span>' : '<span style="' . $cssPrice . '">' . $currencies->display_price($this->productsInfo[$i]['products_price'], tep_get_tax_rate($this->productsInfo[$i]['products_tax_class_id'])) . '</span>';
			$html_content .= $price . '</td>';
			$col = 0;
		}else{
			$html_content .= '<td align="center" width="' . $width . '%"><a href="' . tep_catalog_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $this->productsInfo[$i]['products_id']) . '" style="' . $cssLink . '">' . tep_image(HTTP_CATALOG_SERVER . DIR_WS_CATALOG_IMAGES . $this->productsInfo[$i]['products_image'], $this->productsInfo[$i]['products_name']) . '<br>' . $this->productsInfo[$i]['products_name'] . '</a><br>';
			$price = ($this->productsInfo[$i]['specials_price']) ? '<span style="' . $cssMarkdown . '">' . $currencies->display_price($this->productsInfo[$i]['products_price'], tep_get_tax_rate($this->productsInfo[$i]['products_tax_class_id'])) . '</span>  <span style="' . $cssSale . '">' . $currencies->display_price($this->productsInfo[$i]['specials_price'], tep_get_tax_rate($this->productsInfo[$i]['products_tax_class_id'])) . '</span>' : '<span style="' . $cssPrice . '">' . $currencies->display_price($this->productsInfo[$i]['products_price'], tep_get_tax_rate($this->productsInfo[$i]['products_tax_class_id'])) . '</span>';
			$html_content .= $price . '</td>';

 

 

with this bit of code:

 

 

$html_content .= '</tr><tr><td align="center" valign="bottom" width="' . $width . '%" bgcolor="#ffffff" height="150"><a href="' . tep_email_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $this->productsInfo[$i]['products_id']) . '" style="' . $cssLink . '"><span style"' . $cssImage . '">' . tep_image(HTTP_CATALOG_SERVER_EMAIL . DIR_WS_CATALOG_IMAGES_EMAIL . $this->productsInfo[$i]['products_image'], $this->productsInfo[$i]['products_name'], 120) . '</span><br>' . $this->productsInfo[$i]['products_name'] . '</a><br>';
			$price = ($this->productsInfo[$i]['specials_price']) ? '<span style="'. $cssMarkdown . '">' . $currencies->display_price($this->productsInfo[$i]['products_price'], tep_get_tax_rate($this->productsInfo[$i]['products_tax_class_id'])) . '</span>  <span style="' . $cssSale . '">' . $currencies->display_price($this->productsInfo[$i]['specials_price'], tep_get_tax_rate($this->productsInfo[$i]['products_tax_class_id'])) . '</span>' : '<span style="' . $cssPrice . '">' . $currencies->display_price($this->productsInfo[$i]['products_price'], tep_get_tax_rate($this->productsInfo[$i]['products_tax_class_id'])) . '</span>';
			$html_content .= $price . '</td>';
			$col = 0;
		}else{
			$html_content .= '<td align="center" valign="bottom" width="' . $width . '%" bgcolor="#ffffff" height="150"><a href="' . tep_email_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $this->productsInfo[$i]['products_id']) . '" style="' . $cssLink . '">' . tep_image(HTTP_CATALOG_SERVER_EMAIL . DIR_WS_CATALOG_IMAGES_EMAIL . $this->productsInfo[$i]['products_image'], $this->productsInfo[$i]['products_name'], 120) . '<br>' . $this->productsInfo[$i]['products_name'] . '</a><br>';
			$price = ($this->productsInfo[$i]['specials_price']) ? '<span style="' . $cssMarkdown . '">' . $currencies->display_price($this->productsInfo[$i]['products_price'], tep_get_tax_rate($this->productsInfo[$i]['products_tax_class_id'])) . '</span>  <span style="' . $cssSale . '">' . $currencies->display_price($this->productsInfo[$i]['specials_price'], tep_get_tax_rate($this->productsInfo[$i]['products_tax_class_id'])) . '</span>' : '<span style="' . $cssPrice . '">' . $currencies->display_price($this->productsInfo[$i]['products_price'], tep_get_tax_rate($this->productsInfo[$i]['products_tax_class_id'])) . '</span>';
			$html_content .= $price . '</td>';

 

 

It's working great and although it shows scaled down original images in the admin preview, in the received email you can see crystal clear images scaled properly by the image resizer which is part of MaxiDVD. Maybe this is a solution to the problems people have been having with the MaxiDVD mod, which, by the way, is excellent!

Edited by sonictrip.net

Share this post


Link to post
Share on other sites

The problem im now facing is trying to get a limited amount of characters of the product description to display beside the product name, image and price in the newsletter.

 

Has anyone figured out a way to do this and if so would they mind sharing the code please? Thanks! :)

Share this post


Link to post
Share on other sites

Hi Scottyb

Thank you for great contribution but please why I have twwo times price? Please where I can change it, you can see how it works on images:

old price EUR [old price in SKK] special price EUR [special price in SKK] special price EUR [special price in SKK] / special price EUR [special price in SKK]

 

I want only old price EUR [old price in SKK] special pice EUR [special price in SKK]

here is picture:

newsletter.jpg

 

Thank you for help

Share this post


Link to post
Share on other sites

Great contribution. Thanks. I am receiving the below Warning though for a file that had no modifications:

 

Warning: reset() [function.reset]: Passed variable is not an array or object in /home2/doubled1/public_html/admin/includes/classes/object_info.php on line 17

 

Warning: Variable passed to each() is not an array or object in /home2/doubled1/public_html/admin/includes/classes/object_info.php on line 18

 

Do you know what the ???

 

Appreciate your help.

Share this post


Link to post
Share on other sites
Hi Scottyb

Thank you for great contribution but please why I have twwo times price? Please where I can change it, you can see how it works on images:

old price EUR [old price in SKK] special price EUR [special price in SKK] special price EUR [special price in SKK] / special price EUR [special price in SKK]

 

I want only old price EUR [old price in SKK] special pice EUR [special price in SKK]

here is picture:

newsletter.jpg

 

Thank you for help

 

It works for me fine. Check the installation again.

Share this post


Link to post
Share on other sites

Today I have uploaded a new update to Newsletter Product.

 

With this update you will get properly resized thumbnails for your newsletter just in 3 steps.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×