Пример #1
0
  std::string
  ImapClient::fetchFrom(const std::string& aHost,
                        const std::string& aUserName,
                        const std::string& aPassword,
                        const std::string& aMailbox,
                        const unsigned long aMessageNumber) {
    
#include "linkage.c"
    
    MAILSTREAM* lSource = getMailStream(aHost, aUserName, aPassword, aMailbox, true); 
    
    char lResult[256];
    mail_fetchsubject(lResult, lSource, aMessageNumber, (unsigned long)255);
    return std::string(lResult);
  }
Пример #2
0
Variant f_imap_headerinfo(const Resource& imap_stream, int64_t msg_number,
                          int64_t fromlength /* = 0 */,
                          int64_t subjectlength /* = 0 */,
                          const String& defaulthost /* = "" */) {
  ImapStream *obj = imap_stream.getTyped<ImapStream>();
  if (fromlength < 0 || fromlength > MAILTMPLEN) {
    Logger::Warning("From length has to be between 0 and %d", MAILTMPLEN);
    return false;
  }
  if (subjectlength < 0 || subjectlength > MAILTMPLEN) {
    Logger::Warning("Subject length has to be between 0 and %d", MAILTMPLEN);
    return false;
  }
  if (!obj->checkMsgNumber(msg_number)) {
    return false;
  }
  if (!mail_fetchstructure(obj->m_stream, msg_number, NIL)) {
    return false;
  }

  MESSAGECACHE *cache = mail_elt(obj->m_stream, msg_number);
  ENVELOPE *en = mail_fetchenvelope(obj->m_stream, msg_number);

  /* call a function to parse all the text, so that we can use the
     same function to parse text from other sources */
  Object ret = _php_make_header_object(en);

  /* now run through properties that are only going to be returned
     from a server, not text headers */
  ret.o_set("Recent",   cache->recent ? (cache->seen ? "R": "N") : " ");
  ret.o_set("Unseen",   (cache->recent | cache->seen) ? " " : "U");
  ret.o_set("Flagged",  cache->flagged  ? "F" : " ");
  ret.o_set("Answered", cache->answered ? "A" : " ");
  ret.o_set("Deleted",  cache->deleted  ? "D" : " ");
  ret.o_set("Draft",    cache->draft    ? "X" : " ");

  char dummy[2000], fulladdress[MAILTMPLEN + 1];
  snprintf(dummy, sizeof(dummy), "%4ld", cache->msgno);
  ret.o_set("Msgno", String(dummy, CopyString));

  mail_date(dummy, cache);
  ret.o_set("MailDate", String(dummy, CopyString));

  snprintf(dummy, sizeof(dummy), "%ld", cache->rfc822_size);
  ret.o_set("Size", String(dummy, CopyString));

  ret.o_set("udate", (int64_t)mail_longdate(cache));

  if (en->from && fromlength) {
    fulladdress[0] = 0x00;
    mail_fetchfrom(fulladdress, obj->m_stream, msg_number, fromlength);
    ret.o_set("fetchfrom", String(fulladdress, CopyString));
  }
  if (en->subject && subjectlength) {
    fulladdress[0] = 0x00;
    mail_fetchsubject(fulladdress, obj->m_stream, msg_number, subjectlength);
    ret.o_set("fetchsubject", String(fulladdress, CopyString));
  }

  return ret;
}