unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Rasmus <rasmus@gmx.us>
To: nljlistbox2@gmail.com
Cc: help-gnu-emacs@gnu.org
Subject: Re: Multiple "outgoing" email accounts.
Date: Mon, 10 Feb 2014 12:07:15 +0100	[thread overview]
Message-ID: <87d2iv5iqk.fsf@gmx.us> (raw)
In-Reply-To: <87txcaku5g.fsf@ericabrahamsen.net> (Eric Abrahamsen's message of "Sat, 08 Feb 2014 14:14:51 +0800")

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> nljlistbox2@gmail.com (N. Jackson) writes:
>
>> "William G Gardella" <wgg2@member.fsf.org> writes:
>>> N.B. that in emacs24, you can also specify which SMTP server to use
>>> for message-mode on a per message basis with an
>>> "X-Message-SMTP-Method:" header, e.g.
>>>
>>> X-Message-SMTP-Method: smtp smtp.foo.org 465
>>>
>>> This eliminates much of the need for the setting of individual
>>> smtpmail-* variables in these multiple accounts configurations for
>>> message-mode MUAs like mu4e and Gnus.  This technique also lets you
>>> switch between use of smtpmail and use of your system's local sendmail
>>> binary:
>>>
>>> X-Message-SMTP-Method: sendmail
>>>
>>> See (info "(message) Mail Variables") for more info.
>>
>> I've been looking at using this header for in my set up for multiple
>> email accounts and I find myself with questions that I haven't found the
>> answers to yet in the documentation:
>>
>> !. Does the header get removed before the mail is sent?
>>
>> 2. Can one omit the port number and leave that to be retrieved from the
>> .authinfo file?
>>
>> 3. Is there a command to insert the X-Message-SMTP-Method header?
>>
>> 4. When entering the value for the X-Message-SMTP-Method header, is
>> there a way to use completion to select from available smtp servers, or
>> from the entries in .authinfo?
>>
>> It would seem like an excessive amount of work, and error prone, to type
>> in something like
>>
>>      X-Message-SMTP-Method: smtp smtp.fsf.org 587 other-user
>>
>> every time I want to send an email.
>
> I think the idea is to use posting styles to tell gnus to set up the
> appropriate STMP method header, depending on your From address. As far
> as I know, however, that means you can't cycle the From address in the
> message-mode buffer and have it do the right thing. You'd have specify
> the From address before the message buffer is set up. I'm looking at
> this now, and I'll probably set up a wrapper around compose-mail.

Here's a simplified version of the ugly hack I use to do this.  

(defun rasmus/compose-mail (&optional arg)
  "Compose a mail with the possibility to choose a style if ARG is non-nil"
  (interactive "P")
  (require 'gnus-util)
  (unless (gnus-alive-p) (gnus) (bury-buffer))
  (if (not arg)
        (compose-mail)
      (let* ((accounts (mapcar (lambda (x)
                                 (let ((adr (cadr (assoc 'GCC x))));; TODO: fragile
                                   (cons
                                    (replace-regexp-in-string ".*:\\([[:ascii:]]+\\)/.*" "\\1" adr)
                                    adr)))
                               gnus-posting-styles))
             (choice (ido-completing-read "Choose account" (mapcar 'car accounts)))
             (gnus-newsgroup-name (cdr-safe (assoc choice accounts))))
        (gnus-summary-mail-other-window))))


nljlistbox2@gmail.com (N. Jackson) writes:

> And what about the settings of variables like smtpmail-smtp-service,
> smtpmail-starttls-credentials, smtpmail-auth-credentials etc.? Do they
> get factored in to the mix, or are they ignored when the
> "X-Message-SMTP-Method" header is used?

You set that in your posting style as well.  Here's an example (the
eval line in the end).

  (setq gnus-posting-styles
        '(((lambda () (rasmus/gnus-posting-style-identify "school"
                       '("To" . "rasmus@school\\.edu")
                        (lambda () (pank/message-mailto-test "school\\.edu"))))
           (address "rasmus@school.eu")
           ;; (Face (gnus-convert-png-to-face (expand-file-name "school.png" gnus-face-direcotry)))
           (Organization "School")
           (GCC "nnimap+mail:school/sent")
           (X-Message-SMTP-Method "smtp server.com 587 rasmus@school.edu")
           (signature "My sig")
           (eval (setq smtpmail-stream-type nil)))))

Also, the X-message-SMTP-Method seems to be stripped from a quick test
(examining a raw message send to myself).

Hope it helps,
Rasmus

-- 
Enough with the bla bla!



  reply	other threads:[~2014-02-10 11:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-06 20:30 Multiple "outgoing" email accounts E Sabof
2014-02-06 20:47 ` Herbert J. Skuhra
2014-02-06 22:02   ` E Sabof
2014-02-07 17:42     ` William G Gardella
     [not found]     ` <mailman.14081.1391794971.10748.help-gnu-emacs@gnu.org>
2014-02-08  4:22       ` N. Jackson
2014-02-08  6:14         ` Eric Abrahamsen
2014-02-10 11:07           ` Rasmus [this message]
     [not found]         ` <mailman.14149.1391839983.10748.help-gnu-emacs@gnu.org>
2014-02-08 19:46           ` N. Jackson
2014-02-07  0:34 ` E Sabof

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d2iv5iqk.fsf@gmx.us \
    --to=rasmus@gmx.us \
    --cc=help-gnu-emacs@gnu.org \
    --cc=nljlistbox2@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).