You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

mu4e搭配msmtp发送邮件后未保存至Sent目录问题求助

Fixing mu4e Not Saving Sent Emails to Yahoo's Sent Folder (with msmtp & Contexts)

Hey, I’ve dealt with this exact problem before when setting up mu4e with msmtp and multiple contexts—so I know how frustrating it is when sent emails don’t land where they’re supposed to. Let’s break down the fixes that worked for me:

1. Explicitly Set the Sent Folder in Your Yahoo Context

The most common culprit is that your Yahoo context isn’t explicitly telling mu4e where to save sent messages. Even if you think it’s the default, you need to define mu4e-sent-folder and mu4e-sent-messages-behavior for the context. Update your context configuration like this:

(setq mu4e-contexts
      `(,(make-mu4e-context
          :name "Yahoo"
          :match-func (lambda (msg)
                        (when msg
                          (string-prefix-p "/yahoo" (mu4e-message-field msg :maildir))))
          :vars '((user-mail-address . "your-yahoo-account@yahoo.com")
                  (mu4e-sent-folder . "/yahoo/Sent") ; Critical: points to your local Sent dir
                  (mu4e-sent-messages-behavior . sent) ; Tells mu4e to save locally, not rely on server
                  (smtpmail-smtp-server . "smtp.mail.yahoo.com")
                  ; Add your other msmtp/context-specific vars here
                  ))))

The sent value for mu4e-sent-messages-behavior ensures mu4e handles saving the message locally instead of waiting for Yahoo’s server to sync the Sent folder (which can be unreliable with msmtp).

2. Make Sure mu4e Uses the Right Send Function

If you’ve customized how mu4e sends mail, double-check that you’re using a function that plays nice with local saves. Stick with the standard setup:

(setq mu4e-send-mail-function 'smtpmail-send-it)

If you’re using the mu4e-msmtp package, use mu4e-msmtp-send-it instead—this wrapper is built to integrate mu4e’s save workflow with msmtp properly.

3. Verify Your Maildir Structure & Permissions

Sometimes the issue is just that the Sent folder doesn’t exist, or mu4e doesn’t have write access. Run these terminal commands to fix that:

# Check if the folder exists
ls -ld ~/Maildir/yahoo/Sent

# Create it if it's missing
mkdir -p ~/Maildir/yahoo/Sent

# Lock down permissions (only you should access your mail)
chmod -R 700 ~/Maildir

4. Test Context Application & Manual Save

If the above doesn’t work, test if your context is actually being applied when you send mail. Sometimes if you start composing without switching to the Yahoo context first, mu4e uses the default context instead.

To rule that out, after sending a test email, run this in Emacs to manually save the message:

(mu4e-save-message (mu4e-get-compose-buffer) "/yahoo/Sent")

If this works, your context’s match-func might not be correctly identifying when you’re sending from Yahoo. Tweak the match function to check your user-mail-address instead, if needed:

:match-func (lambda (msg)
              (or (null msg) ; Matches new composition buffers
                  (string= (mu4e-message-field msg :from) "your-yahoo-account@yahoo.com")))

5. Don’t Let Global Settings Override Your Context

Make sure the global mu4e-sent-messages-behavior isn’t overriding your context’s setting. Set it to nil so contexts can define their own behavior:

(setq mu4e-sent-messages-behavior nil)

After making these changes, restart Emacs (or reload your config with M-x eval-buffer), send a test email from your Yahoo context, and check ~/Maildir/yahoo/Sent—it should show up there now.

内容的提问来源于stack exchange,提问作者Julian

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 03:38:08