* Multiple gmail accounts and SMTP (again)
@ 2011-07-24 20:55 Johnny
2011-07-25 17:58 ` Sivaram Neelakantan
2011-08-21 4:14 ` Lars Magne Ingebrigtsen
0 siblings, 2 replies; 4+ messages in thread
From: Johnny @ 2011-07-24 20:55 UTC (permalink / raw)
To: ding
I am attempting to set up a second gmail account, and have some trouble
in getting the outgoing mail to behave nicely. Summarising, I want to
send mail from either gmail-account with "From" address set
accordingly. Below, a ramble about my attempts so far.
In setting up the IMAP part, I defined the virtual server names and used
those in authinfo to successfully differentiate between the accounts:
In .gnus.el:
(nnimap "gmail1"
(nnimap-address "imap.gmail.com")
(nnimap-server-port 993)
(nnimap-stream ssl)
(nnimap-list-pattern inbox-)
)
(nnimap "gmail2"
(nnimap-address "imap.gmail.com")
(nnimap-server-port 993)
(nnimap-stream ssl)
(nnimap-list-pattern inbox-)
)
And then in .authinfo:
machine gmail1 login gmail1@gmail.com password gmail1pass port 993
machine gmail2 login gmail2@gmail.com password gmail2pass port 993
This makes the IMAP work well. All good so far.
(For SMTP, I am using the emacs-wiki setup, as described here: http://www.emacswiki.org/emacs/MultipleSMTPAccounts)
I then attempted to use virtual server names for SMTP as well, i.e.:
In .gnus.el:
(setq smtp-accounts '(
(ssl "gmail1" "smtp.gmail.com" "587"
"gmail1@gmail.com" nil)
(ssl "gmail2" "smtp.gmail.com" "587"
"gmail2@gmail.com" nil)))
And in authinfo:
machine gmail1 login gmail1@gmail.com password gmail1pass port 587
machine gmail2 login gmail2@gmail.com password gmail2pass port 587
This breaks the sendmail/authinfo functionality such that I have to
enter credentials every time sending mail from either account.
If I instead replace the 2 lines above in authinfo with:
machine smtp.gmail.com login gmail1@gmail.com password gmail1pass port 587
This makes mailing from both addresses work. I /think/ the setup makes
gmail2 use gmail1's SMTP credentials to send the mail (note that I
didn't have to do any changes in .gnus.el on the gmail2 credentials),
and indeed, when it is received, the posting-styles for gmail2 is used,
but the senders mail address has been changed to gmail1, which I do not
fancy at all.
Any ideas on how to enable using either gmail as sender?
Cheers
--
Johnny
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Multiple gmail accounts and SMTP (again)
2011-07-24 20:55 Multiple gmail accounts and SMTP (again) Johnny
@ 2011-07-25 17:58 ` Sivaram Neelakantan
2011-07-25 20:23 ` Johnny
2011-08-21 4:14 ` Lars Magne Ingebrigtsen
1 sibling, 1 reply; 4+ messages in thread
From: Sivaram Neelakantan @ 2011-07-25 17:58 UTC (permalink / raw)
To: ding
On Mon, Jul 25 2011,Johnny wrote:
[snipped 28 lines]
> (For SMTP, I am using the emacs-wiki setup, as described here:
> http://www.emacswiki.org/emacs/MultipleSMTPAccounts)
>
> I then attempted to use virtual server names for SMTP as well, i.e.:
> In .gnus.el:
> (setq smtp-accounts '(
> (ssl "gmail1" "smtp.gmail.com" "587"
> "gmail1@gmail.com" nil)
> (ssl "gmail2" "smtp.gmail.com" "587"
> "gmail2@gmail.com" nil)))
>
> And in authinfo:
> machine gmail1 login gmail1@gmail.com password gmail1pass port 587
> machine gmail2 login gmail2@gmail.com password gmail2pass port 587
>
> This breaks the sendmail/authinfo functionality such that I have to
> enter credentials every time sending mail from either account.
>
> If I instead replace the 2 lines above in authinfo with:
> machine smtp.gmail.com login gmail1@gmail.com password gmail1pass port 587
>
> This makes mailing from both addresses work. I /think/ the setup makes
> gmail2 use gmail1's SMTP credentials to send the mail (note that I
> didn't have to do any changes in .gnus.el on the gmail2 credentials),
> and indeed, when it is received, the posting-styles for gmail2 is used,
> but the senders mail address has been changed to gmail1, which I do not
> fancy at all.
>
> Any ideas on how to enable using either gmail as sender?
>
> Cheers
Can you post your customised sendmail parts that you took from
http://www.emacswiki.org/emacs/MultipleSMTPAccounts
It's possible that smtp-mail-address is not getting correctly picked up?
sivaram
--
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Multiple gmail accounts and SMTP (again)
2011-07-25 17:58 ` Sivaram Neelakantan
@ 2011-07-25 20:23 ` Johnny
0 siblings, 0 replies; 4+ messages in thread
From: Johnny @ 2011-07-25 20:23 UTC (permalink / raw)
To: Sivaram Neelakantan; +Cc: ding
Sivaram Neelakantan <nsivaram.net@gmail.com> writes:
> On Mon, Jul 25 2011,Johnny wrote:
>
>
> [snipped 28 lines]
>
>> (For SMTP, I am using the emacs-wiki setup, as described here:
>> http://www.emacswiki.org/emacs/MultipleSMTPAccounts)
>>
>> I then attempted to use virtual server names for SMTP as well, i.e.:
>> In .gnus.el:
>> (setq smtp-accounts '(
>> (ssl "gmail1" "smtp.gmail.com" "587"
>> "gmail1@gmail.com" nil)
>> (ssl "gmail2" "smtp.gmail.com" "587"
>> "gmail2@gmail.com" nil)))
And using the cusomtised sendmail parts from
http://www.emacswiki.org/emacs/MultipleSMTPAccounts as:
;; Now lets configure smtpmail.el with your name and functions to send
;; mail using your smtp accounts by changing the from field
(require 'smtpmail)
(setq send-mail-function 'smtpmail-send-it message-send-mail-function
'smtpmail-send-it mail-from-style nil user-full-name "Your name" smtpmail-debug-info t smtpmail-debug-verb t)
;Update only the smtp-accounts, gnus-posting-styles and the .authinfo.gpg
(defun set-smtp (mech server port user password)
"Set related SMTP variables for supplied parameters."
(setq smtpmail-smtp-server server
smtpmail-default-smtp-server server
smtpmail-smtp-service port
smtpmail-auth-credentials (list (list server port user password))
smtpmail-auth-supported (list mech)
smtpmail-starttls-credentials nil)
(message "Setting SMTP server to `%s:%s' for user `%s'."
server port user))
(defun set-smtp-ssl (server port user password &optional key cert)
"Set related SMTP and SSL variables for supplied parameters."
(setq starttls-use-gnutls t
starttls-gnutls-program "gnutls-cli"
smtpmail-default-smtp-server server
;; TODO: Add this to the server parameters
;; starttls-extra-arguments nil
smtpmail-smtp-server server
smtpmail-smtp-service port
smtpmail-auth-credentials (list (list server port user password))
smtpmail-starttls-credentials (list (list server port key cert)))
(message
"Setting SMTP server to `%s:%s' for user `%s'. (SSL enabled.) Key: `%s' Cert: `%s' Pass: `%s'"
server port user key cert password))
(defun change-smtp ()
"Change the SMTP server according to the current from line."
(interactive)
(save-excursion
(loop with from = (save-restriction
(message-narrow-to-headers)
(message-fetch-field "from"))
for (auth-mech address . auth-spec) in smtp-accounts
when (string-match address from)
do (cond
((memq auth-mech '(cram-md5 plain login))
(return (apply 'set-smtp (cons auth-mech auth-spec))))
((eql auth-mech 'ssl)
(return (apply 'set-smtp-ssl auth-spec)))
(t (error "Unrecognized SMTP auth. mechanism: `%s'." auth-mech)))
finally (error "Cannot infer SMTP information."))))
(defvar %smtpmail-via-smtp (symbol-function 'smtpmail-via-smtp))
(defun smtpmail-via-smtp (recipient smtpmail-text-buffer)
(with-current-buffer smtpmail-text-buffer (change-smtp))
(funcall (symbol-value '%smtpmail-via-smtp) recipient smtpmail-text-buffer))
>>
>> And in authinfo:
>> machine gmail1 login gmail1@gmail.com password gmail1pass port 587
>> machine gmail2 login gmail2@gmail.com password gmail2pass port 587
>>
>> This breaks the sendmail/authinfo functionality such that I have to
>> enter credentials every time sending mail from either account.
>>
>> If I instead replace the 2 lines above in authinfo with:
>> machine smtp.gmail.com login gmail1@gmail.com password gmail1pass port 587
>>
>> This makes mailing from both addresses work. I /think/ the setup makes
>> gmail2 use gmail1's SMTP credentials to send the mail (note that I
>> didn't have to do any changes in .gnus.el on the gmail2 credentials),
>> and indeed, when it is received, the posting-styles for gmail2 is used,
>> but the senders mail address has been changed to gmail1, which I do not
>> fancy at all.
>
> Can you post your customised sendmail parts that you took from
> http://www.emacswiki.org/emacs/MultipleSMTPAccounts
I amended the code as it appears in my .gnus.el above.
>
> It's possible that smtp-mail-address is not getting correctly picked up?
Maybe, but I don't know how to debug. I have hacked away on a copy/paste
trial/error basis. Not too academic, but hey, sometimes it works. Alas,
not this time...
cheers
--
Johnny
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Multiple gmail accounts and SMTP (again)
2011-07-24 20:55 Multiple gmail accounts and SMTP (again) Johnny
2011-07-25 17:58 ` Sivaram Neelakantan
@ 2011-08-21 4:14 ` Lars Magne Ingebrigtsen
1 sibling, 0 replies; 4+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-08-21 4:14 UTC (permalink / raw)
To: Johnny; +Cc: ding
Johnny <yggdrasil@gmx.co.uk> writes:
> Any ideas on how to enable using either gmail as sender?
Well, it may not be much help for Emacs 23 users, but I've added a
`smtpmail-smtp-user' variable to Emacs 24 now which should allow picking
the right set of credentials there.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog http://lars.ingebrigtsen.no/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-08-21 4:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-24 20:55 Multiple gmail accounts and SMTP (again) Johnny
2011-07-25 17:58 ` Sivaram Neelakantan
2011-07-25 20:23 ` Johnny
2011-08-21 4:14 ` Lars Magne Ingebrigtsen
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 NNTP newsgroup(s).