Sending emails with attachments through maligun


(side note: I also posted this on stackoverflow)
I am trying to send a log file through mailgun from my Ionic 2 app on an Android device. The file is a plain-text csv file, that I successfully created earlier in the app with File.writeFile command:

File.writeFile(cordova.file.externalRootDirectory, "data.csv", "...")
I am able to send emails through Mailgun, so I know that the basic configuration is set up correctly. Emails get sent (including subject and text) but without the attachment. My latest approach was:

let formData = new FormData();
    formData.append("from", "");
    formData.append("to", "");
    formData.append("subject", "test");
    formData.append("text", "plain email works");
    formData.append("attachment", cordova.file.externalRootDirectory + 'data.csv');"", formData)
  .map(result => result.json())
  .do(result => console.log("RESULT", JSON.stringify(result)))
  .subscribe(result => {
  }, error => {

I also tried to explicitly state the Content-Type:

let headers = new Headers(
        "Content-Type": "multipart/form-data",
        "Authorization": "Basic " + MYAPIKEY //(base64 encoded)
let options = new RequestOptions({headers: headers});""+this.mailgunUrl+"/messages", formData, options)

Instead of passing just path and filename I also tried to use File.getFile but without much success. Would be great if someone could help. Thanks a lot!


Did you ever get this figured out? Trying the same thing myself.


Unfortunately not. I ended up sending the content of the file in the emails text field.



Sorry, I did no further work on that.