From: Felipe Contreras Date: Wed, 23 Apr 2014 21:49:44 +0000 (+1900) Subject: [PATCH 3/3] Improve the way messages are sent X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4050a2244505e7297e5aef12b1e75969174b2321;p=notmuch-archives.git [PATCH 3/3] Improve the way messages are sent --- diff --git a/57/47b9452017a15847d22fd91f1674a036467f9c b/57/47b9452017a15847d22fd91f1674a036467f9c new file mode 100644 index 000000000..67f4675ac --- /dev/null +++ b/57/47b9452017a15847d22fd91f1674a036467f9c @@ -0,0 +1,161 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 10762431FC9 + for ; Wed, 23 Apr 2014 15:00:27 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.799 +X-Spam-Level: +X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 6c2cbsoe-EyT for ; + Wed, 23 Apr 2014 15:00:19 -0700 (PDT) +Received: from mail-oa0-f51.google.com (mail-oa0-f51.google.com + [209.85.219.51]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 118BA431FC0 + for ; Wed, 23 Apr 2014 15:00:19 -0700 (PDT) +Received: by mail-oa0-f51.google.com with SMTP id i4so1744627oah.10 + for ; Wed, 23 Apr 2014 15:00:18 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:in-reply-to:references; + bh=5WZrBGwG+Wq/OIRrgoXg0bUVHp8n8sI5fjDkKl0vLcE=; + b=uVkI9/AGQKAq6+991s0LF9bSa4bhze0Utf6+6ZjekeunRmPOomBNRrGsIfe9gRIOkP + ioKqwnUZyfetohPh4qk/CVDAIQczcY4HEYTadq+Qsfy+Fhl+rawEPTTfJDJVu3UMZxbR + bdHcrpUzJnV0A4LAezYUokdiAnknbXBmYS1/ugD1BjyJBantD3dF6NkpmBVFxTCYFfn8 + uqRxNWzse6Kalhu+jtwYbCOi4kSyxvDUrNflbHoGpZe+mgpNu0kboCLYqO/Op2i1K55M + v/nQC99K4L+aQFDKcQXjpEqRrSK2YI/TkoD9N2d/b156AwfQhMyikmvKYxxckr9GY82Q + hTNA== +X-Received: by 10.60.159.36 with SMTP id wz4mr45262159oeb.30.1398290418554; + Wed, 23 Apr 2014 15:00:18 -0700 (PDT) +Received: from localhost (189-211-224-40.static.axtel.net. [189.211.224.40]) + by mx.google.com with ESMTPSA id pa3sm4331609obb.6.2014.04.23.15.00.16 + for + (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Wed, 23 Apr 2014 15:00:17 -0700 (PDT) +From: Felipe Contreras +To: notmuch@notmuchmail.org +Subject: [PATCH 3/3] Improve the way messages are sent +Date: Wed, 23 Apr 2014 16:49:44 -0500 +Message-Id: <1398289784-18203-4-git-send-email-felipe.contreras@gmail.com> +X-Mailer: git-send-email 1.9.2+fc1.2.gfbaae8c +In-Reply-To: <1398289784-18203-1-git-send-email-felipe.contreras@gmail.com> +References: <1398289784-18203-1-git-send-email-felipe.contreras@gmail.com> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Wed, 23 Apr 2014 22:00:27 -0000 + +We want the proper encoding and content-type to be set when sending the +mail, but human-readable plain-text for composing. So split the code in +two parts: the presentation and the transport conversion. + +Signed-off-by: Felipe Contreras +--- + vim/notmuch.vim | 34 +++++++++++++++++++++------------- + 1 file changed, 21 insertions(+), 13 deletions(-) + +diff --git a/vim/notmuch.vim b/vim/notmuch.vim +index 0cb94f6..331e930 100644 +--- a/vim/notmuch.vim ++++ b/vim/notmuch.vim +@@ -86,17 +86,22 @@ endfunction + function! s:compose_send() + let b:compose_done = 1 + let fname = expand('%') ++ let lines = getline(5, '$') + +- " remove headers +- 0,4d +- write ++ruby << EOF ++ # Generate proper mail to send ++ text = VIM::evaluate('lines').join("\n") ++ fname = VIM::evaluate('fname') ++ transport = Mail.new(text) ++ transport.message_id = generate_message_id ++ transport.charset = 'utf-8' ++ File.write(fname, transport.to_s) ++EOF + + let cmdtxt = g:notmuch_sendmail . ' -t -f ' . s:reply_from . ' < ' . fname + let out = system(cmdtxt) + let err = v:shell_error + if err +- undo +- write + echohl Error + echo 'Eeek! unable to send mail' + echo out +@@ -572,9 +577,7 @@ ruby << EOF + end + m.cc = orig[:cc] + m.from = $email +- m.message_id = generate_message_id + m.charset = 'utf-8' +- m.content_transfer_encoding = '7bit' + end + + lines = [] +@@ -600,7 +603,7 @@ ruby << EOF + + reply.body = body_lines.join("\n") + +- lines += reply.to_s.lines.map { |e| e.chomp } ++ lines += reply.present.lines.map { |e| e.chomp } + lines << "" + + cur = lines.count - 1 +@@ -611,18 +614,13 @@ ruby << EOF + def open_compose() + lines = [] + +- lines << "Date: #{Time.now().strftime('%a, %-d %b %Y %T %z')}" + lines << "From: #{$email}" + lines << "To: " + cur = lines.count + + lines << "Cc: " + lines << "Bcc: " +- lines << "Message-Id: #{generate_message_id}" + lines << "Subject: " +- lines << "Mime-Version: 1.0" +- lines << "Content-Type: text/plain; charset=utf-8" +- lines << "Content-Transfer-Encoding: 7bit" + lines << "" + lines << "" + lines << "" +@@ -928,6 +926,16 @@ ruby << EOF + end + text + end ++ ++ def present ++ buffer = '' ++ header.fields.each do |f| ++ buffer << "%s: %s\r\n" % [f.name, f.to_s] ++ end ++ buffer << "\r\n" ++ buffer << body.to_s ++ buffer ++ end + end + end + +-- +1.9.2+fc1.2.gfbaae8c +