Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6137423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:43:27+00:00 2026-05-23T17:43:27+00:00

I need to attach a file to the email Magento sends when a client

  • 0

I need to attach a file to the email Magento sends when a client places an order.

This attachment can be either a PDF, a HTML or a simple TXT, and it must have the summary of the order (SKU, Quantity, Unit Price, Total Price).

How can I go about making this happen?

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:43:27+00:00Added an answer on May 23, 2026 at 5:43 pm

    Solution is not very complex, although you’ll need some time to implement it. I’ll give there brief explanation of all the steps required.

    The main steps are:

    1. Compose your attachment in Order mail and pass it to the mailer
    2. Transit it to Email template
    3. Add it to actual letter sent as attachment

    1) You need to rewrite the Mage_Sales_Model_Order class. Overwrite the `sendNewOrderEmail()’ method in that class.

    There you need to compose the attachment, that you want to send to the customer. Copy the original sendNewOrderEmail() method source code to your overwriting method and put the following lines just before $mailer->send() (for our example we will take the easy case – we will send a text file, that will contain only Grand Total of an order, attachment will be named ‘summary.txt’)

    $fileContents = "Hello, here is the copy of your invoice:\n";
    $fileContents .= sprintf("Grand total: %.2f", $this->getGrandTotal()) . "\n";
    $fileContents .= "Thank you for your visit!";
    $fileName = 'summary.txt';
    $mailer->addAttachment($fileContents, $fileName);
    

    2) Rewrite Mage_Core_Model_Email_Template_Mailer – add there method addAttachment($fileContents, $fileName), that will add passed attachments to protected variable, that stores array of attachments.

    Overwrite send() method in this class. In that method you will need to pass array of attachments to every email template sent. E.g. add lines like

    $emailTemplate->setAttachments($this->getAttachments());
    

    right before line $emailTemplate->setDesignConfig...

    3) Rewrite Mage_Core_Model_Email_Template.

    Add there method setAttachments($attachments), that must set incoming attachments to some protected variable.

    Overwrite send() method in this class. In that method you will need to add attachments to the sent letter. Put the lines like

    foreach ($this->getAttachments() as $atInfo) {
        $attachment = $mail->createAttachment($atInfo['fileContents']);
        $attachment->filename = $atInfo['fileName'];
    }
    

    right before $mail->send() line there.

    That’s all. It is really not very hard to do this task for a Magento developer. It just requires some time to compose contents, rewrite classes and complete interfaces.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to attach a file with mailx but at the moment I am
I need to convert some files to PDF and then attach them to an
I'm using Apache Commons Email 1.1 and I can't figure out how to attach
I need to attach an XLS-file to e-mail via PHP. The Problem is -
I need to attach some javascript to the onchange event of the Zend_Form_Element. How
Lets say you need to attach some JavaScript functionality to an ASP.NET User Control
When I attach functionality to an element do I need to call .widgetName('destroy') before
Normally to attach a debuger to a running jvm you would need start the
Need to an expression that returns only things with an I followed by either
I know how to read a file on the server and attach it to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.