Gnus development mailing list
 help / color / mirror / Atom feed
* Can't send message through smtp with gmail
@ 2012-06-27 10:25 mihkel
  2012-06-27 22:28 ` Katsumi Yamaoka
  0 siblings, 1 reply; 8+ messages in thread
From: mihkel @ 2012-06-27 10:25 UTC (permalink / raw)
  To: ding

Hi.

Recently I upgraded to Fedora 17 and to Emacs 24.
M-x emacs-version:
GNU Emacs 24.0.97.1 (x86_64-redhat-linux-gnu, GTK+ Version 2.24.10) of
2012-05-21 on x86-15.phx2.fedoraproject.org
M-x gnus-version
Ma Gnus v0.6

After that upgrade I can't send any messages. Error that is shown in
Messages buffer is:

Sending via mail...
Setting SMTP server to `smtp.gmail.com:587' for user `turakas@gmail.com'. (SSL
enabled.)
530-5.5.1 Authentication Required. Learn more at
530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257
f7sm9942572wiv.2
221 2.0.0 closing connection f7sm9942572wiv.2
byte-code: Wrong number of arguments: (lambda (recipient
smtpmail-text-buffer) (with-current-buffer smtpmail-text-buff\
er (change-smtp)) (funcall (symbol-value (quote %smtpmail-via-smtp))
recipient smtpmail-text-buffer)), 3


I think the relevant snippet from gnus init file is:

(require 'smtpmail)
(setq send-mail-function 'smtpmail-send-it
      message-send-mail-function 'smtpmail-send-it
      mail-from-style nil
      smtpmail-debug-info t
      smtpmail-debug-verb t)



 (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))


I guess I should also mention that I use multiple gmail accounts+isp
mail account+gmane news server for news.
I tried to google the error message and searched this mailing list,
but found nothing. At least not any obvious solution. Is there
something changed during Emacs 23 to Emacs 24 upgrade that I should
know?

mihkel



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Can't send message through smtp with gmail
  2012-06-27 10:25 Can't send message through smtp with gmail mihkel
@ 2012-06-27 22:28 ` Katsumi Yamaoka
  2012-06-28 15:03   ` mihkel
  0 siblings, 1 reply; 8+ messages in thread
From: Katsumi Yamaoka @ 2012-06-27 22:28 UTC (permalink / raw)
  To: mihkel; +Cc: ding

mihkel wrote:
> Recently I upgraded to Fedora 17 and to Emacs 24.
> M-x emacs-version:
> GNU Emacs 24.0.97.1 (x86_64-redhat-linux-gnu, GTK+ Version 2.24.10) of
> 2012-05-21 on x86-15.phx2.fedoraproject.org
> M-x gnus-version
> Ma Gnus v0.6

> After that upgrade I can't send any messages. Error that is shown in
> Messages buffer is:

[...]

> I think the relevant snippet from gnus init file is:

[...]

>  (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))

[...]

`smtpmail-via-smtp' now takes three arguments:

(smtpmail-via-smtp RECIPIENT SMTPMAIL-TEXT-BUFFER &optional
ASK-FOR-PASSWORD)

How about replacing those `(defvar ...' and `(defun ...' with
the defadvice form as follows rather than redefining the function?

(defadvice smtpmail-via-smtp (before change-smtp activate)
  "Run `change-smtp' in advance."
  (with-current-buffer smtpmail-text-buffer
    (change-smtp)))

This is essentially the same, but you don't have to care
the arguments spec change.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Can't send message through smtp with gmail
  2012-06-27 22:28 ` Katsumi Yamaoka
@ 2012-06-28 15:03   ` mihkel
  2012-06-28 17:40     ` Richard Riley
  0 siblings, 1 reply; 8+ messages in thread
From: mihkel @ 2012-06-28 15:03 UTC (permalink / raw)
  To: Katsumi Yamaoka; +Cc: ding

Hi and thanks for reply.

On Thu, Jun 28, 2012 at 1:28 AM, Katsumi Yamaoka <yamaoka@jpl.org> wrote:
> (smtpmail-via-smtp RECIPIENT SMTPMAIL-TEXT-BUFFER &optional
> ASK-FOR-PASSWORD)
>
> How about replacing those `(defvar ...' and `(defun ...' with
> the defadvice form as follows rather than redefining the function?
>
> (defadvice smtpmail-via-smtp (before change-smtp activate)
>  "Run `change-smtp' in advance."
>  (with-current-buffer smtpmail-text-buffer
>    (change-smtp)))
>
> This is essentially the same, but you don't have to care
> the arguments spec change.

I changed these two defvar and defun with defadvice as you suggested.
Now when I send a message gnus asks for a SMTP user name for
smtp.gmail.com. When I enter one, then all messages go through this
smtp account. I have this snippet for changing smtp server according
to "from" filed.


;; Change smtp server according to "from" field
(defun change-smtp ()
  "Change the SMTP server according to the current from line."
  (save-excursion
    (loop with from = (save-restriction
			(message-narrow-to-headers)
                        (message-fetch-field "from"))
          for (acc-type address . auth-spec) in smtp-accounts
          when (string-match address from)
          do (cond
              ((eql acc-type 'plain)
               (return (apply 'set-smtp-plain auth-spec)))
              ((eql acc-type 'ssl)
               (return (apply 'set-smtp-ssl auth-spec)))
              (t (error "Unrecognized SMTP account type: '%s'." acc-type)))
          finally (error "Cannot interfere SMTP information."))))

Does the defadvice code change mentioned above break this function? I
really have to ask you to bear with me, since I'm not a programmer...
just a emacs user :)


mihkel



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Can't send message through smtp with gmail
  2012-06-28 15:03   ` mihkel
@ 2012-06-28 17:40     ` Richard Riley
  2012-06-28 20:45       ` mihkel
  0 siblings, 1 reply; 8+ messages in thread
From: Richard Riley @ 2012-06-28 17:40 UTC (permalink / raw)
  To: ding

mihkel <turakas@gmail.com> writes:

> Hi and thanks for reply.
>
> On Thu, Jun 28, 2012 at 1:28 AM, Katsumi Yamaoka <yamaoka@jpl.org> wrote:
>> (smtpmail-via-smtp RECIPIENT SMTPMAIL-TEXT-BUFFER &optional
>> ASK-FOR-PASSWORD)
>>
>> How about replacing those `(defvar ...' and `(defun ...' with
>> the defadvice form as follows rather than redefining the function?
>>
>> (defadvice smtpmail-via-smtp (before change-smtp activate)
>>  "Run `change-smtp' in advance."
>>  (with-current-buffer smtpmail-text-buffer
>>    (change-smtp)))
>>
>> This is essentially the same, but you don't have to care
>> the arguments spec change.
>
> I changed these two defvar and defun with defadvice as you suggested.
> Now when I send a message gnus asks for a SMTP user name for
> smtp.gmail.com. When I enter one, then all messages go through this
> smtp account. I have this snippet for changing smtp server according
> to "from" filed.
>
> ;; Change smtp server according to "from" field
> (defun change-smtp ()
>   "Change the SMTP server according to the current from line."
>   (save-excursion
>     (loop with from = (save-restriction
> 			(message-narrow-to-headers)
>                         (message-fetch-field "from"))
>           for (acc-type address . auth-spec) in smtp-accounts
>           when (string-match address from)
>           do (cond
>               ((eql acc-type 'plain)
>                (return (apply 'set-smtp-plain auth-spec)))
>               ((eql acc-type 'ssl)
>                (return (apply 'set-smtp-ssl auth-spec)))
>               (t (error "Unrecognized SMTP account type: '%s'." acc-type)))
>           finally (error "Cannot interfere SMTP information."))))
>
> Does the defadvice code change mentioned above break this function? I
> really have to ask you to bear with me, since I'm not a programmer...
> just a emacs user :)
>
> mihkel
>

my advice would be to use nognus and the built in multi smtp support.

in your .authinfo:

something like:

machine smtp.gmail.com login accid1 port 587 password password1
machine smtp.gmail.com login accid2 port 587 password password2

In your gnus posting styles for the group in question:-

			     (X-Message-SMTP-Method "smtp smtp.gmail.com 587 acc1")

Its there somewhere in the gnus manual. But googling for
x-message-smtp-method will show a previous thread on this.

regards

r.




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Can't send message through smtp with gmail
  2012-06-28 17:40     ` Richard Riley
@ 2012-06-28 20:45       ` mihkel
  2012-06-28 23:47         ` Richard Riley
  0 siblings, 1 reply; 8+ messages in thread
From: mihkel @ 2012-06-28 20:45 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 1736 bytes --]

Richard Riley <rileyrg@gmail.com> writes:
>
> my advice would be to use nognus and the built in multi smtp support.
>
> in your .authinfo:
>
> something like:
>
> machine smtp.gmail.com login accid1 port 587 password password1
> machine smtp.gmail.com login accid2 port 587 password password2
>
> In your gnus posting styles for the group in question:-
>
> 			     (X-Message-SMTP-Method "smtp smtp.gmail.com 587 acc1")
>
> Its there somewhere in the gnus manual. But googling for
> x-message-smtp-method will show a previous thread on this.
>
> regards
>
> r.


Hi.

I took your advice and it works great. Thanks!

Now my gnus init file look alot cleaner. I was able to discard 
(defvar smtp-accounts ...)
(defadvice smtpmail-via-smtp ... )
(defun change-smtp () ... )

Just for those who tackle with the same problem. My updated
gnus-posting-style looks like this:

;; Let Gnus change the "From:" line by looking at current group we are
;; in.
(setq gnus-posting-styles
      '(("account1"
	  (address "account1@gmail.com")
	  (name "myname")
	  (X-Message-SMTP-Method "smtp smtp.gmail.com 587 account1@gmail.com"))
	 ("account2"
	  (address "account2@gmail.com")
	  (name "myname")
	  (X-Message-SMTP-Method "smtp smtp.gmail.com 587 account2@gmail.com")) 
	 ("account3"
	  (address "account3@gmail.com")
	  (name "myname")
	  (X-Message-SMTP-Method "smtp smtp.gmail.com 587 account3@gmail.com"))
	 ("account4"
	  (address "account4@gmail.com")
	  (name "myname")
	  (X-Message-SMTP-Method "smtp smtp.gmail.com 587 chino.toru@gmail.com"))
	 ("account5" (address "account5@hot.ee")
	  (name "myname")
	  (X-Message-SMTP-Method "smtp mail.hot.ee 25 account5"))
	 ))


mihkel

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Can't send message through smtp with gmail
  2012-06-28 20:45       ` mihkel
@ 2012-06-28 23:47         ` Richard Riley
  2012-06-29  6:46           ` mihkel
  0 siblings, 1 reply; 8+ messages in thread
From: Richard Riley @ 2012-06-28 23:47 UTC (permalink / raw)
  To: ding

mihkel <turakas@gmail.com> writes:

> Richard Riley <rileyrg@gmail.com> writes:
>>
>> my advice would be to use nognus and the built in multi smtp support.
>>
>> in your .authinfo:
>>
>> something like:
>>
>> machine smtp.gmail.com login accid1 port 587 password password1
>> machine smtp.gmail.com login accid2 port 587 password password2
>>
>> In your gnus posting styles for the group in question:-
>>
>> 			     (X-Message-SMTP-Method "smtp smtp.gmail.com 587 acc1")
>>
>> Its there somewhere in the gnus manual. But googling for
>> x-message-smtp-method will show a previous thread on this.
>>
>> regards
>>
>> r.
>
> Hi.
>
> I took your advice and it works great. Thanks!
>
> Now my gnus init file look alot cleaner. I was able to discard 
> (defvar smtp-accounts ...)
> (defadvice smtpmail-via-smtp ... )
> (defun change-smtp () ... )
>
> Just for those who tackle with the same problem. My updated
> gnus-posting-style looks like this:
>
> ;; Let Gnus change the "From:" line by looking at current group we are
> ;; in.
> (setq gnus-posting-styles
>       '(("account1"
> 	  (address "account1@gmail.com")
> 	  (name "myname")
> 	  (X-Message-SMTP-Method "smtp smtp.gmail.com 587 account1@gmail.com"))
> 	 ("account2"
> 	  (address "account2@gmail.com")
> 	  (name "myname")
> 	  (X-Message-SMTP-Method "smtp smtp.gmail.com 587 account2@gmail.com")) 
> 	 ("account3"
> 	  (address "account3@gmail.com")
> 	  (name "myname")
> 	  (X-Message-SMTP-Method "smtp smtp.gmail.com 587 account3@gmail.com"))
> 	 ("account4"
> 	  (address "account4@gmail.com")
> 	  (name "myname")
> 	  (X-Message-SMTP-Method "smtp smtp.gmail.com 587 chino.toru@gmail.com"))
> 	 ("account5" (address "account5@hot.ee")
> 	  (name "myname")
> 	  (X-Message-SMTP-Method "smtp mail.hot.ee 25 account5"))
> 	 ))
>
> mihkel
>

Glad it worked for you. Its complicated and somewhat hard to figure out
without examples and especially if you dont know posting styles etc
previously. Next thing to do is set up authfiles as gpg. Keeping
important email passwords (which are often the same as important account
ones) in plain text files is bordering on lunacy. Assuming youre using
Linux then look into gpg-agent and keychain.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Can't send message through smtp with gmail
  2012-06-28 23:47         ` Richard Riley
@ 2012-06-29  6:46           ` mihkel
  2012-06-29  9:29             ` Richard Riley
  0 siblings, 1 reply; 8+ messages in thread
From: mihkel @ 2012-06-29  6:46 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 575 bytes --]

Richard Riley <rileyrg@gmail.com> writes:
>
> Glad it worked for you. Its complicated and somewhat hard to figure out
> without examples and especially if you dont know posting styles etc
> previously. Next thing to do is set up authfiles as gpg. Keeping
> important email passwords (which are often the same as important account
> ones) in plain text files is bordering on lunacy. Assuming youre using
> Linux then look into gpg-agent and keychain.


Actually I've been using .authinfo.gpg from the beginning... about a
year since I set up gnus for the first time.


mihkel

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Can't send message through smtp with gmail
  2012-06-29  6:46           ` mihkel
@ 2012-06-29  9:29             ` Richard Riley
  0 siblings, 0 replies; 8+ messages in thread
From: Richard Riley @ 2012-06-29  9:29 UTC (permalink / raw)
  To: ding

mihkel <turakas@gmail.com> writes:

> Richard Riley <rileyrg@gmail.com> writes:
>>
>> Glad it worked for you. Its complicated and somewhat hard to figure out
>> without examples and especially if you dont know posting styles etc
>> previously. Next thing to do is set up authfiles as gpg. Keeping
>> important email passwords (which are often the same as important account
>> ones) in plain text files is bordering on lunacy. Assuming youre using
>> Linux then look into gpg-agent and keychain.
>
> Actually I've been using .authinfo.gpg from the beginning... about a
> year since I set up gnus for the first time.
>
> mihkel
>

Its a great feature!

If I have (or mybe someone else reading this) the time sometime soon
these examples could go on the wiki which contains all the multi-smtp
hacks.




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-06-29  9:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-27 10:25 Can't send message through smtp with gmail mihkel
2012-06-27 22:28 ` Katsumi Yamaoka
2012-06-28 15:03   ` mihkel
2012-06-28 17:40     ` Richard Riley
2012-06-28 20:45       ` mihkel
2012-06-28 23:47         ` Richard Riley
2012-06-29  6:46           ` mihkel
2012-06-29  9:29             ` Richard Riley

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).