Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disposable Temporary Email with attachment download API support [closed]

I am working on an application that uses guerrillamail to get temporary email and then I use its given API's to get the contents of emails sent to this id. What I am not able to achieve is that if email contains attachment how can I download it using API or parse the MIME using a mime parser library if I have the email source?

Or can you please recommend any alternative that provide API support to download attachments.

like image 545
Mobile Developer iOS Android Avatar asked Jun 19 '15 07:06

Mobile Developer iOS Android


1 Answers

I tried to see if I could find an answer, so I made some code that seems to work:

var template_content = $("#mail")[0].content;
var tep = $("#mail");

function getMail(id, mail_id) {
  $.get("https://api.guerrillamail.com/ajax.php?f=fetch_email&lang=en&sid_token=" + id + "&email_id=" + mail_id, function(mail) {
    console.log("Mail:");
    console.log(mail);
    template_content.querySelector('p:nth-of-type(1)').innerHTML = mail.mail_from;
    template_content.querySelector('p:nth-of-type(2)').innerHTML = mail.mail_subject;
    template_content.querySelector('p:nth-of-type(3)').innerHTML = mail.mail_body;
    if (mail.att == 0) {
      template_content.querySelector('span').innerHTML = "-none-";
    } else {
      var sp = template_content.querySelector('span');
      $.each(mail.att_info, function(l, att) {
        console.log(att);
        var a = document.createElement('a');
        console.log(a);
        var linkText = document.createTextNode(att.f + " [" + att.t + "]");
        a.appendChild(linkText);
        a.title = att.f + " [" + att.t + "]";
        a.href = "https://www.guerrillamail.com/inbox?get_att&lang=en&sid_token=" + id + "&email_id=" + mail.mail_id + "&part_id=" + att.p;
        sp.appendChild(a);
      });
    }
    var clone = document.importNode(template_content, true);
    document.querySelector('#mails').appendChild(clone);
  });
}

$.get("https://api.guerrillamail.com/ajax.php?f=get_email_address&lang=en", function(data) {
  var email = data.email_addr;
  var id = data.sid_token;
  $("#email_addr").text(email);
  $("#pane").show();

  $("#get").click(function() {
    $.get("https://api.guerrillamail.com/ajax.php?f=get_email_list&lang=en&sid_token=" + id + "&offset=0", function(data) {
      console.log(data.list);
      var tep = $("#mail");
      $.each(data.list, function(i, mail) {
        getMail(id, mail.mail_id)
      });
    });
  });
});
p {
  display: inline
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div id="pane" style="display:none">
  <p>Send email with attachment to [<b id="email_addr">frefr</b>] and press the button:</p>
  <button id="get">Get mails!</button>
</div>

<br/>
<br/>

<div id="mails">

</div>


<template id="mail">
  <div>
    <h2>Mail</h2>
    Sender:
    <p>1</p>
    <br/>Subject:
    <p>2</p>
    <br/>Body:
    <br/>
    <hr/>
    <p>3</p>
    <br/>
    <hr/>Attachments:
    <br>
    <span></span>
  </div>
</template>

I can't find any info about the attachment stuff in the documentation, but in my code I used the "normal" attachment link, and it seems to work:

https://www.guerrillamail.com/inbox?get_att&lang=en&sid_token={sid_token}&email_id={email_id}&part_id={part_id}";

Look at my example code to see how to use it.

You seem to have most of the code done on the iPhone side, basically you just have to add a call to the get_att url with the att parameters from the fetch_email.

like image 87
ZombieSpy Avatar answered Nov 15 '22 05:11

ZombieSpy