Skip to content

Attaching files #63

Description

@8vius

I don't quite get how to attach files to an email, I checked the API and it says it should be under the content.attachments section as an array, yet doing this doesn't seem to work, this is how I'm sending my email:

  def buyer_tickets_email(order)
    @order = order
    data = {
      substitution_data: purchase_order_details(@order),
      content: {
        attachments: order.tickets.map do |ticket|
          {
            name: "#{ticket_file_name(ticket)}.pdf",
            type: "application/pdf",
            data: ticket.to_pdf
          }
        end
      },
      template_id: 'buyer-tickets-email'
    }
    mail to: @order.email, subject: I18n.t('tickets_mailer.subject'), sparkpost_data: data
  end

Am I missing something? The email arrives correctly yet without the attached pdfs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions