⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 send.c

📁 mutt-1.5.12 源代码。linux 下邮件接受的工具。
💻 C
📖 第 1 页 / 共 3 页
字号:
  }  if (!msg->env->from && option (OPTUSEFROM) && !(flags & (SENDPOSTPONED|SENDRESEND)))    msg->env->from = mutt_default_from ();  if (flags & SENDBATCH)   {    mutt_copy_stream (stdin, tempfp);    if (option (OPTHDRS))    {      process_user_recips (msg->env);      process_user_header (msg->env);    }    mutt_expand_aliases_env (msg->env);  }  else if (! (flags & (SENDPOSTPONED|SENDRESEND)))  {    if ((flags & (SENDREPLY | SENDFORWARD)) && ctx &&	envelope_defaults (msg->env, ctx, cur, flags) == -1)      goto cleanup;    if (option (OPTHDRS))      process_user_recips (msg->env);    /* Expand aliases and remove duplicates/crossrefs */    mutt_fix_reply_recipients (msg->env);    if (! (flags & SENDMAILX) &&	! (option (OPTAUTOEDIT) && option (OPTEDITHDRS)) &&	! ((flags & SENDREPLY) && option (OPTFASTREPLY)))    {      if (edit_envelope (msg->env) == -1)	goto cleanup;    }    /* the from address must be set here regardless of whether or not     * $use_from is set so that the `~P' (from you) operator in send-hook     * patterns will work.  if $use_from is unset, the from address is killed     * after send-hooks are evaulated */    if (!msg->env->from)    {      msg->env->from = mutt_default_from ();      killfrom = 1;    }    if ((flags & SENDREPLY) && cur)    {      /* change setting based upon message we are replying to */      mutt_message_hook (ctx, cur, M_REPLYHOOK);      /*       * set the replied flag for the message we are generating so that the       * user can use ~Q in a send-hook to know when reply-hook's are also       * being used.       */      msg->replied = 1;    }    /* change settings based upon recipients */        mutt_message_hook (NULL, msg, M_SENDHOOK);    /*     * Unset the replied flag from the message we are composing since it is     * no longer required.  This is done here because the FCC'd copy of     * this message was erroneously get the 'R'eplied flag when stored in     * a maildir-style mailbox.     */    msg->replied = 0;    if (killfrom)    {      rfc822_free_address (&msg->env->from);      killfrom = 0;    }    if (option (OPTHDRS))      process_user_header (msg->env);    if (option (OPTSIGONTOP) && (! (flags & (SENDMAILX | SENDKEY)) && Editor && mutt_strcmp (Editor, "builtin") != 0))      append_signature (tempfp);    /* include replies/forwarded messages, unless we are given a template */    if (!tempfile && (ctx || !(flags & (SENDREPLY|SENDFORWARD)))	&& generate_body (tempfp, msg, flags, ctx, cur) == -1)      goto cleanup;    if (!option (OPTSIGONTOP) && (! (flags & (SENDMAILX | SENDKEY)) && Editor && mutt_strcmp (Editor, "builtin") != 0))      append_signature (tempfp);    /*      * this wants to be done _after_ generate_body, so message-hooks     * can take effect.     */    if (WithCrypto && !(flags & SENDMAILX))    {      if (option (OPTCRYPTAUTOSIGN))	msg->security |= SIGN;      if (option (OPTCRYPTAUTOENCRYPT))	msg->security |= ENCRYPT;      if (option (OPTCRYPTREPLYENCRYPT) && cur && (cur->security & ENCRYPT))	msg->security |= ENCRYPT;      if (option (OPTCRYPTREPLYSIGN) && cur && (cur->security & SIGN))	msg->security |= SIGN;      if (option (OPTCRYPTREPLYSIGNENCRYPTED) && cur && (cur->security & ENCRYPT))	msg->security |= SIGN;      if (WithCrypto & APPLICATION_PGP && (msg->security & (ENCRYPT | SIGN)))      {	if (option (OPTPGPAUTOINLINE))	  msg->security |= INLINE;	if (option (OPTPGPREPLYINLINE) && cur && (cur->security & INLINE))	  msg->security |= INLINE;      }    }    if (WithCrypto && msg->security)    {      /*        * When reypling / forwarding, use the original message's       * crypto system.  According to the documentation,       * smime_is_default should be disregarded here.       *        * Problem: At least with forwarding, this doesn't really       * make much sense. Should we have an option to completely       * disable individual mechanisms at run-time?       */      if (cur)      {	if ((WithCrypto & APPLICATION_PGP) && option (OPTCRYPTAUTOPGP) 	    && (cur->security & APPLICATION_PGP))	  msg->security |= APPLICATION_PGP;	else if ((WithCrypto & APPLICATION_SMIME) && option (OPTCRYPTAUTOSMIME)		 && (cur->security & APPLICATION_SMIME))	  msg->security |= APPLICATION_SMIME;      }            /*       * No crypto mechanism selected? Use availability + smime_is_default       * for the decision.        */      if (!(msg->security & (APPLICATION_SMIME | APPLICATION_PGP)))      {	if ((WithCrypto & APPLICATION_SMIME) && option (OPTCRYPTAUTOSMIME) 	    && option (OPTSMIMEISDEFAULT))	  msg->security |= APPLICATION_SMIME;	else if ((WithCrypto & APPLICATION_PGP) && option (OPTCRYPTAUTOPGP))	  msg->security |= APPLICATION_PGP;	else if ((WithCrypto & APPLICATION_SMIME) && option (OPTCRYPTAUTOSMIME))	  msg->security |= APPLICATION_SMIME;      }    }        /* No permissible mechanisms found.  Don't sign or encrypt. */    if (!(msg->security & (APPLICATION_SMIME|APPLICATION_PGP)))      msg->security = 0;  }    /*    * This hook is even called for postponed messages, and can, e.g., be   * used for setting the editor, the sendmail path, or the   * envelope sender.   */  mutt_message_hook (NULL, msg, M_SEND2HOOK);    /* wait until now to set the real name portion of our return address so     that $realname can be set in a send-hook */  if (msg->env->from && !msg->env->from->personal      && !(flags & (SENDRESEND|SENDPOSTPONED)))    msg->env->from->personal = safe_strdup (Realname);  if (!((WithCrypto & APPLICATION_PGP) && (flags & SENDKEY)))    safe_fclose (&tempfp);  if (flags & SENDMAILX)  {    if (mutt_builtin_editor (msg->content->filename, msg, cur) == -1)      goto cleanup;  }  else if (! (flags & SENDBATCH))  {    struct stat st;    time_t mtime = mutt_decrease_mtime (msg->content->filename, NULL);    mutt_update_encoding (msg->content);    /*     * Select whether or not the user's editor should be called now.  We     * don't want to do this when:     * 1) we are sending a key/cert     * 2) we are forwarding a message and the user doesn't want to edit it.     *    This is controled by the quadoption $forward_edit.  However, if     *    both $edit_headers and $autoedit are set, we want to ignore the     *    setting of $forward_edit because the user probably needs to add the     *    recipients.     */    if (! (flags & SENDKEY) &&	((flags & SENDFORWARD) == 0 ||	 (option (OPTEDITHDRS) && option (OPTAUTOEDIT)) ||	 query_quadoption (OPT_FORWEDIT, _("Edit forwarded message?")) == M_YES))    {      /* If the this isn't a text message, look for a mailcap edit command */      if (mutt_needs_mailcap (msg->content))      {	if (!mutt_edit_attachment (msg->content))          goto cleanup;      }      else if (!Editor || mutt_strcmp ("builtin", Editor) == 0)	mutt_builtin_editor (msg->content->filename, msg, cur);      else if (option (OPTEDITHDRS))      {	mutt_env_to_local (msg->env);	mutt_edit_headers (Editor, msg->content->filename, msg, fcc, sizeof (fcc));	mutt_env_to_idna (msg->env, NULL, NULL);      }      else      {	mutt_edit_file (Editor, msg->content->filename);	if (stat (msg->content->filename, &st) == 0)	{	  if (mtime != st.st_mtime)	    fix_end_of_file (msg->content->filename);	}	else	  mutt_perror (msg->content->filename);      }            mutt_message_hook (NULL, msg, M_SEND2HOOK);    }    if (! (flags & (SENDPOSTPONED | SENDFORWARD | SENDKEY | SENDRESEND)))    {      if (stat (msg->content->filename, &st) == 0)      {	/* if the file was not modified, bail out now */	if (mtime == st.st_mtime && !msg->content->next &&	    query_quadoption (OPT_ABORT, _("Abort unmodified message?")) == M_YES)	{	  mutt_message _("Aborted unmodified message.");	  goto cleanup;	}      }      else	mutt_perror (msg->content->filename);    }  }  /* specify a default fcc.  if we are in batchmode, only save a copy of   * the message if the value of $copy is yes or ask-yes */  if (!fcc[0] && !(flags & (SENDPOSTPONED)) && (!(flags & SENDBATCH) || (quadoption (OPT_COPY) & 0x1)))  {    /* set the default FCC */    if (!msg->env->from)    {      msg->env->from = mutt_default_from ();      killfrom = 1; /* no need to check $use_from because if the user specified		       a from address it would have already been set by now */    }    mutt_select_fcc (fcc, sizeof (fcc), msg);    if (killfrom)    {      rfc822_free_address (&msg->env->from);      killfrom = 0;    }  }    mutt_update_encoding (msg->content);  if (! (flags & (SENDMAILX | SENDBATCH)))  {main_loop:    fcc_error = 0; /* reset value since we may have failed before */    mutt_pretty_mailbox (fcc);    i = mutt_compose_menu (msg, fcc, sizeof (fcc), cur);    if (i == -1)    {      /* abort */      mutt_message _("Mail not sent.");      goto cleanup;    }    else if (i == 1)    {      /* postpone the message until later. */      if (msg->content->next)	msg->content = mutt_make_multipart (msg->content);      /*       * make sure the message is written to the right part of a maildir        * postponed folder.       */      msg->read = 0; msg->old = 0;      encode_descriptions (msg->content, 1);      mutt_prepare_envelope (msg->env, 0);      mutt_env_to_idna (msg->env, NULL, NULL);	/* Handle bad IDNAs the next time. */      if (!Postponed || mutt_write_fcc (NONULL (Postponed), msg, (cur && (flags & SENDREPLY)) ? cur->env->message_id : NULL, 1, fcc) < 0)      {	msg->content = mutt_remove_multipart (msg->content);	decode_descriptions (msg->content);	mutt_unprepare_envelope (msg->env);	goto main_loop;      }      mutt_update_num_postponed ();      mutt_message _("Message postponed.");      goto cleanup;    }  }  if (!msg->env->to && !msg->env->cc && !msg->env->bcc)  {    if (! (flags & SENDBATCH))    {      mutt_error _("No recipients are specified!");      goto main_loop;    }    else    {      puts _("No recipients were specified.");      goto cleanup;    }  }  if (mutt_env_to_idna (msg->env, &tag, &err))  {    mutt_error (_("Bad IDN in \"%s\": '%s'"), tag, err);    FREE (&err);    if (!(flags & SENDBATCH))      goto main_loop;    else       goto cleanup;  }    if (!msg->env->subject && ! (flags & SENDBATCH) &&      (i = query_quadoption (OPT_SUBJECT, _("No subject, abort sending?"))) != M_NO)  {    /* if the abort is automatic, print an error message */    if (quadoption (OPT_SUBJECT) == M_YES)      mutt_error _("No subject specified.");    goto main_loop;  }  if (msg->content->next)    msg->content = mutt_make_multipart (msg->content);  /*    * Ok, we need to do it this way instead of handling all fcc stuff in   * one place in order to avoid going to main_loop with encoded "env"   * in case of error.  Ugh.   */  encode_descriptions (msg->content, 1);    /*   * Make sure that clear_content and free_clear_content are   * properly initialized -- we may visit this particular place in   * the code multiple times, including after a failed call to   * mutt_protect().   */    clear_content = NULL;  free_clear_content = 0;    if (WithCrypto)  {    if (msg->security)      {      /* save the decrypted attachments */      clear_content = msg->content;        if ((crypt_get_keys (msg, &pgpkeylist) == -1) ||          mutt_protect (msg, pgpkeylist) == -1)      {        msg->content = mutt_remove_multipart (msg->content);        	FREE (&pgpkeylist);                decode_descriptions (msg->content);        goto main_loop;      }      encode_descriptions (msg->content, 0);    }      /*      * at this point, msg->content is one of the following three things:     * - multipart/signed.  In this case, clear_content is a child.     * - multipart/encrypted.  In this case, clear_content exists     *   independently     * - application/pgp.  In this case, clear_content exists independently.     * - something else.  In this case, it's the same as clear_content.     */      /* This is ugly -- lack of "reporting back" from mutt_protect(). */        if (clear_content && (msg->content != clear_content)        && (msg->content->parts != clear_content))      free_clear_content = 1;  }  if (!option (OPTNOCURSES) && !(flags & SENDMAILX))    mutt_message _("Sending message...");  mutt_prepare_envelope (msg->env, 1);  /* save a copy of the message, if necessary. */  mutt_expand_path (fcc, sizeof (fcc));    /* Don't save a copy when we are in batch-mode, and the FCC   * folder is on an IMAP server: This would involve possibly lots   * of user interaction, which is not available in batch mode.    *    * Note: A patch to fix the problems with the use of IMAP servers   * from non-curses mode is available from Brendan Cully.  However,    * I'd like to think a bit more about this before including it.   */#ifdef USE_IMAP  if ((flags & SENDBATCH) && fcc[0] && mx_is_imap (fcc))    fcc[0] = '\0';#endif  if (*fcc && mutt_strcmp ("/dev/null", fcc) != 0)  {    BODY *tmpbody = msg->content;    BODY *save_sig = NULL;    BODY *save_parts = NULL;    if (WithCrypto && msg->security && option (OPTFCCCLEAR))      msg->content = clear_content;    /* check to see if the user wants copies of all attachments */    if (!option (OPTFCCATTACH) && msg->content->type == TYPEMULTIPART)    {      if (WithCrypto          && (mutt_strcmp (msg->content->subtype, "encrypted") == 0 ||              mutt_strcmp (msg->content->subtype, "signed") == 0))      {	if (clear_content->type == TYPEMULTIPART)	{	  if(!(msg->security & ENCRYPT) && (msg->security & SIGN))	  {	    /* save initial signature and attachments */	    save_sig = msg->content->parts->next;	    save_parts = clear_content->parts->next;	  }	  /* this means writing only the main part */	  msg->content = clear_content->parts;	  if (mutt_protect (msg, pgpkeylist) == -1)	  {	    /* we can't do much about it at this point, so	     * fallback to saving the whole thing to fcc	     */	    msg->content = tmpbody;	    save_sig = NULL;	    goto full_fcc;	  }	  save_content = msg->content;	}      }      else	msg->content = msg->content->parts;    }full_fcc:    if (msg->content)    {      /* update received time so that when storing to a mbox-style folder       * the From_ line contains the current time instead of when the       * message was first postponed.       */      msg->received = time (NULL);      if (mutt_write_fcc (fcc, msg, NULL, 0, NULL) == -1)      {	/*	 * Error writing FCC, we should abort sending.	 */	fcc_error = 1;      }    }    msg->content = tmpbody;    if (WithCrypto && save_sig)    {      /* cleanup the second signature structures */      if (save_content->parts)      {	mutt_free_body (&save_content->parts->next);	save_content->parts = NULL;      }      mutt_free_body (&save_content);      /* restore old signature and attachments */      msg->content->parts->next = save_sig;      msg->content->parts->parts->next = save_parts;    }    else if (WithCrypto && save_content)    {      /* destroy the new encrypted body. */      mutt_free_body (&save_content);    }  }  /*   * Don't attempt to send the message if the FCC failed.  Just pretend   * the send failed as well so we give the user a chance to fix the   * error.   */  if (fcc_error || (i = send_message (msg)) == -1)  {    if (!(flags & SENDBATCH))    {      if (!WithCrypto)        ;      else if ((msg->security & ENCRYPT) ||                ((msg->security & SIGN)                && msg->content->type == TYPEAPPLICATION))      {	mutt_free_body (&msg->content); /* destroy PGP data */	msg->content = clear_content;	/* restore clear text. */      }      else if ((msg->security & SIGN) && msg->content->type == TYPEMULTIPART)      {	mutt_free_body (&msg->content->parts->next);	     /* destroy sig */	msg->content = mutt_remove_multipart (msg->content);       }      msg->content = mutt_remove_multipart (msg->content);      decode_descriptions (msg->content);      mutt_unprepare_envelope (msg->env);      goto main_loop;    }    else    {      puts _("Could not send the message.");      goto cleanup;    }  }  else if (!option (OPTNOCURSES) && ! (flags & SENDMAILX))    mutt_message (i == 0 ? _("Mail sent.") : _("Sending in background."));  if (WithCrypto && (msg->security & ENCRYPT))    FREE (&pgpkeylist);    if (WithCrypto && free_clear_content)    mutt_free_body (&clear_content);  if (flags & SENDREPLY)  {    if (cur && ctx)      mutt_set_flag (ctx, cur, M_REPLIED, 1);    else if (!(flags & SENDPOSTPONED) && ctx && ctx->tagged)    {      for (i = 0; i < ctx->vcount; i++)	if (ctx->hdrs[ctx->v2r[i]]->tagged)	  mutt_set_flag (ctx, ctx->hdrs[ctx->v2r[i]], M_REPLIED, 1);    }  }  rv = 0;  cleanup:  if ((WithCrypto & APPLICATION_PGP) && (flags & SENDPOSTPONED))  {    if(signas)    {      FREE (&PgpSignAs);      PgpSignAs = signas;    }  }     safe_fclose (&tempfp);  mutt_free_header (&msg);    return rv;}/* vim: set sw=2: */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -