Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I download attachment from mailgun #198

Open
thiennhan2310 opened this issue Apr 3, 2018 · 2 comments
Open

How can I download attachment from mailgun #198

thiennhan2310 opened this issue Apr 3, 2018 · 2 comments
Assignees

Comments

@thiennhan2310
Copy link

Could you show me how can i download attachment by the message url ?

@YuvalKaplan
Copy link

I asked Mailgun support this wuestion and they anwered with:

I tried using the request library from the mailgun-js sdk and I was still getting undefined errors. My hunch is the library my not fully support downloading of attachments.

The code they used:

var mailgun = require("mailgun-js");
var Request = require('mailgun-js/lib/request');
var DOMAIN = 'YOUR_DOMAIN_NAME';
var mailgun = require('mailgun-js')({apiKey: 'key-*****************', domain: 'DOMAIN_NAME'});



var options = {
//host will be either sw.api.mailgun.net or se.api.mailgun.net based on the full attachment storage url
   host: 'sw.api.mailgun.net',
   endpoint: '/v3',
   protocol: 'https:',
   port: 443,
   auth: ['api', api_key].join(':'),
   retry: 1
 };

var req = new Request(options);

let response = req.request('GET', `/domains/${DOMAIN}/messages/ATTACHMENT_KEY`, function (error, body) {
  console.log(body);
});

This was after I tested the same and only received 'undefined' in the 'body'.
I guess my answer does not solve your problem :(

I do hope a contributor can answer this.

@bojand bojand self-assigned this Apr 9, 2018
@ziedmahdi
Copy link

@bojand any updates on this.

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

No branches or pull requests

4 participants