Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Newsletter Attachment


mystifier

Recommended Posts

Posted

Has anyone succeeded in adding an attachment to a Newsletter? I like this feature but it is only really useful as an attachment carrier.

 

There is an add_attachment function in admin\includes\classes\email.php but I haven't mananged to make it work.

 

I would greatly appreciate any help or advice.

  • 2 months later...
Posted

I've gotten it to work for adding a pdf file to my confirmation mail, I'll write the code snippets to you here, and then you can see if you can use it in your case:

 

In /classes/email.php in the build_message() function find:

        case (($html == true) && ($attachments == true) && ($html_images == false)):
//Commented out by -rl
/* HPDL PHP3 */
//          $message =& $this->add_mixed_part();
//          $message = $this->add_mixed_part();
//          if (tep_not_null($this->html_text)) {
/* HPDL PHP3 */
//            $alt =& $this->add_alternative_part($message);
//            $alt = $this->add_alternative_part($message);
//            $this->add_text_part($alt, $this->html_text);
//            $this->add_html_part($alt);
//          } else {
//            $this->add_html_part($message);
//          }

//Insert by -rl start

         if (tep_not_null($this->html_text)) {
/* HPDL PHP3 */
//            $message =& $this->add_alternative_part($null);
           $message = $this->add_related_part($null);
           $this->add_text_part($message, $this->html_text);
           $this->add_html_part($message);
         } else {
/* HPDL PHP3 */
//            $message =& $this->add_html_part($null);
           $message = $this->add_html_part($null);
         }

// insert by -rl stop

 

Then the class works, then i functions/general.php find tep_mail() function:

////
//! Send email (text/html) using MIME
// 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. [email protected]
// $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. [email protected]
// Added by -rl
// $attachment_file   relative url to attached file e.g. downloads/filename.pdf
// $attachment_name   name of the file itself e.g. filename.pdf
// $attachment_type   The extension type e.g. application/pdf

 function tep_mail($to_name, $to_email_address, $email_subject, $email_text, $from_email_name, $from_email_address, $attachment_file = false, $attachment_name = false, $attachment_type =false) {
   if (SEND_EMAILS != 'true') return false;

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

if ($attachment_file != false && $attachment_name != false && $attachment_type != false) {
       $attachments = $message->get_file($attachment_file);
       $message->add_attachment($attachments, $attachment_name, $attachment_type);
}

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


   // Send message
   $message->build_message();
   $message->send($to_name, $to_email_address, $from_email_name, $from_email_address, $email_subject, $headers);
 }

 

 

and of course, other emails work, but if you add those threee arguments, you send an attachment as well!

Insert clever remark here

  • 3 weeks later...
Posted

I have used the above to add a text file to an email message. It seems that it attaches the file but there is no content in the file (as though it has just created the file and sent it rather than sending the actual file). I have used the relative url as $attachment_file. Any suggestions?

  • 1 month later...
Posted

Hi,

 

I wish to use the attachment at checkout process.

I added the code to 2 files there is no error, every thing is working normal.

 

Please can you tell me the usage. I am not getting how to add to checkout_process.php,

 

 tep_mail($order->customer['firstname'] . ' ' . $order->customer['lastname'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

 

Thanks in advance,

 

--Kiran

  • 1 year later...
Posted
I have used the above to add a text file to an email message. It seems that it attaches the file but there is no content in the file (as though it has just created the file and sent it rather than sending the actual file). I have used the relative url as $attachment_file. Any suggestions?

 

Sorry for the VERY late reply.

 

You need to use an absolute path for the system for this to work:

 

Nout sure these defines are standard below, but the point still gets across:

 

$attachment_name = DIR_FS_DOWNLOAD . ORDER_ATTACHMENT_PDF;
$attachment_file = ORDER_ATTACHMENT_PDF
$attachment_type = 'application/pdf';

 

This works for adding pdf's, that's really all I've used my code for.

Insert clever remark here

  • 3 weeks later...
Posted
Sorry for the VERY late reply.

 

You need to use an absolute path for the system for this to work:

 

Nout sure these defines are standard below, but the point still gets across:

 

$attachment_name = DIR_FS_DOWNLOAD . ORDER_ATTACHMENT_PDF;
$attachment_file = ORDER_ATTACHMENT_PDF
$attachment_type = 'application/pdf';

 

This works for adding pdf's, that's really all I've used my code for.

 

I've just been told that my fiddle doesn't work with EasyPHP.

 

Haven't tested it though...

Insert clever remark here

Archived

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

×
×
  • Create New...