nicoursi
nicoursi

Reputation: 41

MUTT - how to save sent messages (by different SMTP server) on the IMAP "[Gmail]/Sent Mail" folder

What I need to do is sending emails through my preferred SMTP server but saving those messages to my GMAIL account sent folder on the IMAP server. I am really struggling to do so.

I can send no problem, but I can't save on the imap [Gmail]Sent Mail. Thunderbird can do this flawlessly, so it is only a matter of configuration.

I tried so many things such as:

set record = imaps://imap.gmail.com/INBOX/INVIATA
set record = "+[Gmail]/Sent Mail"
set record = "+[Gmail]/Posta inviata"

It just does not work.

Here is my .muttrc file:

# About Me

set from = "[email protected]"
set realname = "John Doe"
set imap_user = "[email protected]"

# My mailboxes
set imap_pass = $GMAIL_PASS
set folder = imaps://imap.gmail.com/
set spoolfile = imaps://imap.gmail.com/INBOX


# SMTP user auth
# # fill in the right user and pass based on your setup
# # protocols: smtp for TLS (25/587), smtps for SSL (465)

set smtp_url = "smtps://[email protected]@mail.smtpAccount.it:465/"
set smtp_pass = $SMTP_PASS

# Where to save copies of outgoing mail

#here what I have tried so far:
#set record = imaps://imap.gmail.com/SENT
#set record = "imaps://imap.gmail.com/[Gmail]/inviata"
#set record = imaps://imap.gmail.com/INBOX/INVIATA
#set record = "+[Gmail]/Sent Mail"
#set record = "+[Gmail]/Posta inviata"

set record = +[Gmail]/Sent Mail


# Where to put the stuff
set header_cache = "~/.mutt/cache/headers"
set message_cachedir = "~/.mutt/cache/bodies"
set certificate_file = "~/.mutt/certificates"

Upvotes: 2

Views: 1206

Answers (2)

Philipp Moers
Philipp Moers

Reputation: 589

I would guess that it's not possible to save email as sent in Gmail without actually sending it via Gmail's SMTP server. Let me explain.

Gmail doesn't actually use folders, but labels instead. If an email has been sent, it is attached the corresponding label ([Gmail]/Sent Mail), so you can search for it and find it in the "sent folder" later.

To the best of my knowledge, saving to (imaginative) "folders" via IMAP does not have the desired effect of adding labels in Gmail. In fact Gmail treats labels as folders for the purposes of IMAP. As such, labels can be modified using the standard IMAP commands, CREATE, RENAME, and DELETE, that act on folders. But this doesn't seem to apply to the reserved Gmail labels, unfortunately.

The positive news is, Gmail automatically saves sent emails, so you can configure mutt to not save a copy. So by using Gmails SMTP server, you are effectively saving a sent copy without having to sync a sent mailbox directly.


I haven't tried this, but you may be able to achieve what you want by adding this label manually to an email (instead of attempting to save to the sent folder). This would require saving the email to the Gmail INBOX first, however.

Upvotes: 1

ploth
ploth

Reputation: 455

It looks like you want to use the Googles SMTP server. If that is the case, set the record to an empty string as it handles saving the sent mail automatically.

set smtp_url = 'smtps://[email protected]'
set smtp_pass = 'yourpassword'
set record=""

Upvotes: 0

Related Questions