mu4e emacs2 different types for sending mail

97 views
Skip to first unread message

Jim McNamara

unread,
Jul 17, 2022, 9:45:38 PM7/17/22
to mu-discuss
Hi-

Somehow, there are 2 different ways to send email via SMTP in my system, and my emacs is defaulting to the one that I am not configuring. I can receive email okay. I received a message that said kio, and I don't think that is the one i want.

Is there a way I can specify in emacs which method to use when sending email either in a configuration file inside emacs or in external init.el that loads on startup?

It says sending via mail ... and just hangs.

(require 'smtpmail)
(setq
   message-send-mail-function   'smtpmail-send-it
   smtpmail-default-smtp-server "mobile.charter.net"
   smtpmail-smtp-server         "mobile.charter.net"
   smtpmail-local-domain        "myhost.mydomain")

I am using dirks minimal configuration for init.el.

THANKS for any tips!
robo-loki

Jim McNamara

unread,
Jul 17, 2022, 10:29:14 PM7/17/22
to mu-discuss

Hi all-

I am posting the new init.el contents. I did some more work on it.
Please see below.
THANKS

(add-to-list 'load-path "/usr/local/share/emacs/site-lisp/mu4e")
(require 'mu4e)

;; use mu4e for e-mail in emacs
 (setq mail-user-agent 'mu4e-user-agent)
(setq send-mail-function (quote smtpmail-send-it))
(setq mu4e-drafts-folder "/charter/Drafts")
(setq mu4e-trash-folder  "/charter/Trash")

;; don't save message to Sent Messages, Gmail/IMAP takes care of this
(setq mu4e-sent-messages-behavior 'delete)

;; (See the documentation for `mu4e-sent-messages-behavior' if you have
;; additional non-Gmail addresses and want assign them different
;; behavior.)

;; setup some handy shortcuts
;; you can quickly switch to your Inbox -- press ``ji''
;; then, when you want archive some messages, move them to
;; the 'All Mail' folder by pressing ``ma''.

(setq mu4e-maildir-shortcuts
    '( (:maildir "INBOX"              :key ?i)
       (:maildir "Trash"      :key ?t)
       (:maildir "All Mail"   :key ?a)))

;; allow for updating mail using 'U' in the main view:
;;(setq mu4e-get-mail-command "mbsync -a")



;; something about ourselves
(setq
   user-mail-address "51857...@charter.net"
   user-full-name  "my alias"
   mu4e-compose-signature
    (concat
      "Jim M. Mc.Namara\n"
      "http://www.bleepingcomputers.tech\n"))

;; sending mail -- replace USERNAME with your gmail username
;; also, make sure the gnutls command line utils are installed
;; package 'gnutls-bin' in Debian/Ubuntu

(require 'smtpmail)
(setq
   user-mail-address        "51857...@charter.net"
   user-full-name               "my user name  "
   smtpmail-smtp-user           "5185703244"
   smtpmail-default-smtp-server "mobile.charter.net"
   smtpmail-smtp-server         "mobile.charter.net"
   smtpmail-auth-credentials (expand-file-name "~/.authinfo.gpg")
   smtpmail-smtp-service         587
   smtpmail-local-domain        "charter.net")

;; alternatively, for emacs-24 you can use:
;;(setq message-send-mail-function 'smtpmail-send-it
;;     smtpmail-stream-type 'starttls
;;     smtpmail-default-smtp-server "mobile.charter.net"
;;     smtpmail-smtp-server "mobile.charter.net"
;;     smtpmail-smtp-service 587)

;; don't keep message buffers around
(setq message-kill-buffer-on-exit t)

megatron from space

unread,
Jul 18, 2022, 3:33:37 AM7/18/22
to mu-discuss
I am going to try to use proton with mu4e, but probably not this month. I didn't have much luck with mu4e and charter for smtp.
THANKS

Tim Cross

unread,
Jul 18, 2022, 4:40:20 AM7/18/22
to mu-di...@googlegroups.com

It is probably important to note that mu4e doesn't have any direct
relationship with smtp (or imap/pop for that matter). This is all
handled by other libraries (ie. smtpmail for smtp) or applications
(i.e. mbsync for imap). This means you need to look at the
documentation/manuals for whatever package your using i.e. smtpmail and
not the mu4e documentation in order to get the finer details.

With respect to the OPs question about how mu4e selects which smtp
configuration to sue, this is handled in the configuration of your mu4e
'contexts'. For example, I have the following


(add-to-list 'mu4e-contexts
(make-mu4e-context
:name "Outlook"
:vars '((user-mail-address . "XXX...@hotmail.com")
(user-full-name . "XXXXXXXXX")
(mu4e-drafts-folder . "/outlook/Drafts")
(mu4e-sent-folder . "/outlook/Sent")
(mu4e-trash-folder . "/outlook/Deleted")
(mu4e-refile-folder . "/outlook/Archive")
(mu4e-maildir-shortcuts . (("/outlook/INBOX" . ?i)
("/outlook/Sent" . ?s)
("/outlook/Archive" . ?a)
("/outlook/Drafts" . ?d)))
(smtpmail-smtp-server . "smtp-mail.outlook.com")
(smtpmail-smtp-service . 587)
(mu4e-sent-messages-behavior . delete))))

(add-to-list 'mu4e-contexts
(make-mu4e-context
:name "Private"
:vars
'((user-mail-address . "XXXXX...@gmail.com")
(user-full-name . "XXXXXXXXX")
(mu4e-drafts-folder . "/gmail/[Gmail]/Drafts")
(mu4e-sent-folder . "/gmail/[Gmail]/Sent Mail")
(mu4e-trash-folder . "/gmail/[Gmail]/Bin")
(mu4e-refile-folder . "/gmail/Refile")
(mu4e-maildir-shortcuts . (("/gmail/INBOX" . ?i)
("/gmail/Refile" . ?r)
("/gmail/[Gmail]/Drafts" . ?d)
("/gmail/10 - Tech/software/org" . ?g)
("/gmail/10 - Tech/software/gnu" . ?e)
("/gmail/10 - Tech/software/emacspeak" . ?p)))
(smtpmail-smtp-server . "smtp.gmail.com")
(smtpmail-smtp-service . 587)
(mu4e-sent-messages-behavior . delete))))

Note that I've removed some of the additional features available when
defining contgexts (such as defining functions to be run when you
enter/leave a context or a function to select the context based on
message header args etc. Check the manual for full details.

The key point is note the way you can set variables as part of the
context - in particular, the smtpmail-* variables used to control the
smtpmail process.

I also have appropriate lines for these two smtp servers in my
.authinfo.gpg file, which also includes the username/password required
to do the smtp authentication needed before being able to use the remote
smtp server. I don't have any locally configured smtp server.

See the emacs manual for smtpmail and the auth sources section for info
on using .authinfo.gpg
Reply all
Reply to author
Forward
0 new messages