Aller au contenu | Aller au menu | Aller à la recherche


[CLOSED] IMAP connection broken (data)

Moving from Zimbra mail server to Office 365, using imap_append to imap host : outlook.office365.com:993 result a imap error : "[CLOSED] IMAP connection broken (data)" as say imap_last_error.

After sending a mail with PHPMailer i want push him on imap mailbox.

I connect succefully with

$this->mbox = imap_open("{" . $this->host . $this->tags ."}", $this->user, $this->pass, OP_HALFOPEN);

imap_check say :

'Mailbox' => string '{outlook-namwest.office365.com:993/imap/notls/ssl/novalidate-cert/user="myuser@mydomain.com"}<no_mailbox>'
$phpMailer->AddAttachment(__DIR__."/".$localFile, basename(__DIR__."/".$localFile), 'base64', 'application/pdf');
$phpMailer->Send();
$dossierTo = "INBOX";
imap_append($this->mbox, "{" . $this->host ."}" . $dossierTo, $phpMailer->GetSentMIMEMessage());
/**
 * result : 
 * PHP Notice:  Unknown: [CLOSED] IMAP connection broken (data) (errflg=2) in Unknown on line 0
 */

I have not this error with very small mail (little attachment : 606 bytes), but with a little bigger like 26,1 Kb (26 776 bytes) is never working... WHY ?

In php imap sources: imap-2007e, src\c-client\imap4r1.c (or imap4r1.c on fossies.org online) :

long imap_anon (MAILSTREAM *stream,char *tmp)
  if (LOCAL->cap.authanon) {
    char *broken = "[CLOSED] IMAP connection broken (anonymous auth)";
 
long imap_auth (MAILSTREAM *stream,NETMBX *mb,char *tmp,char *usr)
	if (!(reply = &LOCAL->reply)->tag)
	  reply = imap_fake (stream,tag,
			     "[CLOSED] IMAP connection broken (authenticate)");
 
/* IMAP send literal
 * Accepts: MAIL stream
 *	    reply tag
 *	    pointer to current position pointer of output bigbuf
 *	    literal to output as stringstruct
 * Returns: error reply or NIL if success
 */
 
IMAPPARSEDREPLY *imap_send_literal (MAILSTREAM *stream,char *tag,char **s,
				    STRING *st)
{
  IMAPPARSEDREPLY *reply;
  unsigned long i = SIZE (st);
  unsigned long j;
  sprintf (*s,"{%lu}",i);	/* write literal count */
  *s += strlen (*s);		/* size of literal count */
				/* send the command */
  reply = imap_sout (stream,tag,CMDBASE,s);
  if (strcmp (reply->tag,"+")) {/* prompt for more data? */
    mail_unlock (stream);	/* no, give up */
    return reply;
  }
  while (i) {			/* dump the text */
    if (st->cursize) {		/* if text to do in this chunk */
      /* RFC 3501 technically forbids NULs in literals.  Normally, the
       * delivering MTA would take care of MIME converting the message text
       * so that it is NUL-free.  If it doesn't, then we have the choice of
       * either violating IMAP by sending NULs, corrupting the data, or going
       * to lots of work to do MIME conversion in the IMAP server.
       *
       * No current stringstruct driver objects to having its buffer patched.
       * If this ever changes, it will be necessary to change this kludge.
       */
				/* patch NULs to C1 control */
      for (j = 0; j < st->cursize; ++j)
	if (!st->curpos[j]) st->curpos[j] = 0x80;
      if (!net_sout (LOCAL->netstream,st->curpos,st->cursize)) {
	mail_unlock (stream);
	return imap_fake (stream,tag,"[CLOSED] IMAP connection broken (data)");
      }
      i -= st->cursize;		/* note that we wrote out this much */
      st->curpos += (st->cursize - 1);
      st->cursize = 0;
    }
    (*st->dtb->next) (st);	/* advance to next buffer's worth */
  }
  return NIL;			/* success */
}
 
IMAPPARSEDREPLY *imap_sout (MAILSTREAM *stream,char *tag,char *base,char **s)
      imap_fake (stream,tag,"[CLOSED] IMAP connection broken (command)");
 
IMAPPARSEDREPLY *imap_reply (MAILSTREAM *stream,char *tag)
  return imap_fake (stream,tag,
		    "[CLOSED] IMAP connection broken (server response)");

See also exemples in php-src / ext / imap

Ajouter un commentaire

Le code HTML est affiché comme du texte et les adresses web sont automatiquement transformées.

Fil des commentaires de ce billet