Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

attachments #35

Open
samzilverberg opened this issue Feb 22, 2016 · 7 comments
Open

attachments #35

samzilverberg opened this issue Feb 22, 2016 · 7 comments

Comments

@samzilverberg
Copy link

Hi there,

I managed sending attachments with this transport but found it very hard to understand how.

mandrillTransport.sendMail({
  from: '...',
  to : '...',
  ... : ...
  mandrillOptions: {
    message: {
      attachments: [
        {
          type: 'txt',
          name: 'bla.txt',
          content: new Buffer('lalalala').toString('base64')
        }
      ]
    }
  }
, cb })

please document this in your README or even better support the usage of attachments option as documented in nodemailer

If I have time i will try to submit a pr for this support.

@elbuo8
Copy link
Contributor

elbuo8 commented Feb 24, 2016

@samzilverberg feel free to file a PR 👯

@samzilverberg
Copy link
Author

#36
^^ in progress

@olalonde
Copy link

olalonde commented Mar 2, 2016

+1 .. was wondering why attachments weren't working. Reverted to smtp transport for now.

@imatveev
Copy link

Because there a bug, use @samzilverberg attachments-support branch.

@buntarb
Copy link

buntarb commented Mar 23, 2016

Just add

// Fix for this bug.

  for( var prop in payload ){
    if( !(
      prop === 'async' ||
      prop === 'ip_pool' ||
      prop === 'send_at' ||
      prop === 'key' ||
      prop === 'message' ) ){

      payload.message[ prop ] = payload[ prop ];
      delete payload[ prop ];
    }
  }

after line 58 in mandrill-transport.js.
However "best practice" for this situation - separate attachments and images from mandrill API. IMHO.

@mohitagarwal124
Copy link

Seems to be an issue for sending attachement using this package, kindly provide a readme.
Correct way to use
mandrillOptions: {
message: {
attachments: [
{
type: 'txt',
name: 'bla.txt',
content: new Buffer('lalalala').toString('base64')
}
]
}
}

@cyberpluto
Copy link

cyberpluto commented Feb 20, 2018

This can be useful for those who want to use attached images in HTML template.

mandrillOptions: {
  message: {
    images: [
      {
        type: 'image/png',
        name: 'myUniqueCid',
        content: fs.readFileSync('path/to/your/image').toString('base64'),
      }
    ]
  }
}

Usage in template:

<img src="cid:myUniqueCid"/>

Note that it is crucial to add "cid:" before the text "myUniqueCid" which was used in mandrillOptions.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants