I am working to create an email that contains required details for donations to US-based non-profits. In this email, I need to include the donation amount that is collected from a contribution for patrons to file on their taxes with the IRS. I'm not seeing a donation field that I can use, but I have read some posts on custom tokens and needing to add it to Home » CiviCRM » Administer CiviCRM » Custom Data

Is that the process or should I do something else?



2 Answers 2


Use Thank You Letters. This requires you to pull a contribution report of the donors you want to receive the email then create the letter to email them.

  1. Go to Find Contribution, set the date for last year, select the financial type(s), and Refresh Results. Check if you need to do any other filtering to get the people you need.
  2. Check "All Records"
  3. Under actions select "Thank You Letters-Print or Email."
  4. On the Thank You screen Group by "Whatever works for your grouping needs" Separator set to "Horizontal Cell" and select print or email
  5. Create your letter adding token(s) to pull their donations or their {$contribution_aggregate} Whatever detail you want.
  6. Save & Name the template for next time

You will have to create the receipt so it pulls in the information you need. Below is our code. We use line items so you will have to edit this code to your needs.

    <table border="0" style="width: 900px;">
            <td width="30%"><img height="auto" src="logo url here" width="275" /></td>
            <td style="text-align:left; font-weight: bold; padding-top:60px;" width="50%">{contact.addressee}</td>
            <th style="padding-top:60px; text-align:center; color:#70551F;padding-left:100px; ">2021 Contribution Statement</th>
            <td style="text-align:left; " width="40%">{contact.street_address}</td>
            <td style="text-align:center; font-style: italic; color:#281c1d;padding-left:100px;  ">January 1, 2021 - December 31, 2021</td>
            <td width="40%">{contact.city}, {contact.state_province} {contact.postal_code}</td>
            <td style="text-align:center; font-style: italic; color:#281c1d; padding-left:100px; ">Federal Id # 27-4638772</td>

<p style="font-size:18px; font-weight: bold;font-style: italic; color:#70551F;">Thank you for your support of XYZ Foundation in 2021</p>

<p>No goods or services were received for these Tax Deductible contributions</p>

<table align="left" cellpadding="4" cellspacing="0" class="table" style="width: 875px;border: 1px solid #fff;">
        <tr style="padding: 8px; border: 1px solid #fff;color:white; background-color: #70551F;">
            <th style="padding: 8px;">Date</th>
            <th style="padding: 8px;">Cont ID</th>
            <th style="padding: 8px;">Contribution Designation</th>
            <th style="padding: 8px;">Amount</th>

    {foreach from=$contributions item=contribution} {assign
    var="date" value=$contribution.receive_date|date_format:"%B %d %Y"}
{crmAPI var='result' entity='LineItem' action='get' contribution_id=$contribution.id} 
  {foreach from=$result.values item=lineitem} 
        <tr style="padding: 4px; border: 1px solid #281c1d;">
            <td style="font-size:.8em; padding: 1px; border: 1px solid #fff;">{$date}</td>
            <td style="font-size:.8em; padding: 1px; border: 1px solid #fff;">{$contribution.id}</td>
            <td style="font-size:.8em; padding: 1px; border: 1px solid #fff;">{$lineitem.label}</td>
            <td style="font-size:.8em; text-align:right;padding: 1px; border: 1px solid #fff;">$ {$lineitem.line_total}</td>

        <tr style="padding: 3px; border: 1px solid #281c1d;text-align:right;padding-top:10px;">
            <th colspan="3" style="padding: 3px; border: 1px solid #fff;text-align:right;padding-top:10px;padding-right:20px;">2021 Total Contributions</th>
            <td style="padding-right: 4px; border: 1px solid #fff;padding-top:10px;text-align:right;">$ {$contribution_aggregate}</td>

Alternate approach, since I was just wrestling with this: install the Fuzion Tokens extension. It gives you all kinds of useful tokens in various contexts, including things like total amount given this year/last year/all time, total deductible amount ditto.

  • good idea. another option is eg Summary Fields, which then means you can add a token for the 'custom field' which Summary Fields generates when it calculates eg 'last years contributions' (and if you set it to only add up Donations then you should get what you need)
    – petednz - fuzion
    Feb 7, 2022 at 21:34
  • If your contributions only have one line item yes that seems a good approach. But assuming I'm looking at the right line (github.com/eileenmcnaughton/nz.co.fuzion.civitoken/blob/…) the "non-deductible" field in civi may or may not be what you want when there's multiple line items - specifically it gets set to either the whole contribution amount or 0. An example is event + optional donation. Overall this is a suprisingly tricky subject to handle all the use-cases.
    – Demerit
    Feb 8, 2022 at 0:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.