Using Muttt with Gmail - a Howto
Keywords: mutt gmail command line cli
If necessary configure Gmail for multi-factor authentication:
Go to Gmail main page.
Click the Google Apps matrix next to your avatar at the top right.
Click 'Account' in the selection box. It's usually the top left.
Click 'Security'on the left
Scroll down to 'How you sign in to Google'.
Enable '2-step verification'
Get an 'app password':
Instructions found online may be incorrect. Try this:
https: //myaccount.google.com /apppasswords <=== remove the spaces
In the 'App name' field type mutt, then click 'create'.
You should get a 16 letter pass-code, unhelpfully with spaces.
Copy and paste the code to somewhere secure. Remove the spaces.
Install Mutt:
# pkg install mutt
Configure Mutt:
I added this section to the top of the muttrc file. There are several places this can be[1].
Act with caution, it contains you app specific Gmail password in plain text (eeek):
set imap_user = "<your_email>@gmail.com"
set imap_pass = "<pass-code here>"
set smtp_url = "smtp://<your_email>@smtp.gmail.com:587/"
set smtp_pass = $imap_pass
set from = "<your_email>@gmail.com"
set realname = "John Doe"
set ssl_starttls=yes
set ssl_force_tls=yes
set folder = imaps://imap.gmail.com/
set spoolfile = imaps://imap.gmail.com/INBOX
set record="imaps://imap.gmail.com/[Gmail]/Sent Mail"
set postponed="imaps://imap.gmail.com/[Gmail]/Drafts"
set mbox="imaps://imap.gmail.com/[Gmail]/All Mail"
Configure FreeBSD:
edit /etc/rc.conf - add:
sendmail_enable=none
Send test email:
Create a small text file called testemailtext.txt. The space after the title and before the target email address is important.
mutt -s "mutt testemail" <your_email>@gmail.com < testemailtext.txt
Test attachment:
mutt -s "test email with attachment" -a /tmp/cat_pic.png -- <your_email>@gmail.com < testemailtext.txt
great success
[1] I use ~/.muttrc
Keywords: mutt gmail command line cli
If necessary configure Gmail for multi-factor authentication:
Go to Gmail main page.
Click the Google Apps matrix next to your avatar at the top right.
Click 'Account' in the selection box. It's usually the top left.
Click 'Security'on the left
Scroll down to 'How you sign in to Google'.
Enable '2-step verification'
Get an 'app password':
Instructions found online may be incorrect. Try this:
https: //myaccount.google.com /apppasswords <=== remove the spaces
In the 'App name' field type mutt, then click 'create'.
You should get a 16 letter pass-code, unhelpfully with spaces.
Copy and paste the code to somewhere secure. Remove the spaces.
Install Mutt:
# pkg install mutt
Configure Mutt:
I added this section to the top of the muttrc file. There are several places this can be[1].
Act with caution, it contains you app specific Gmail password in plain text (eeek):
set imap_user = "<your_email>@gmail.com"
set imap_pass = "<pass-code here>"
set smtp_url = "smtp://<your_email>@smtp.gmail.com:587/"
set smtp_pass = $imap_pass
set from = "<your_email>@gmail.com"
set realname = "John Doe"
set ssl_starttls=yes
set ssl_force_tls=yes
set folder = imaps://imap.gmail.com/
set spoolfile = imaps://imap.gmail.com/INBOX
set record="imaps://imap.gmail.com/[Gmail]/Sent Mail"
set postponed="imaps://imap.gmail.com/[Gmail]/Drafts"
set mbox="imaps://imap.gmail.com/[Gmail]/All Mail"
Configure FreeBSD:
edit /etc/rc.conf - add:
sendmail_enable=none
Send test email:
Create a small text file called testemailtext.txt. The space after the title and before the target email address is important.
mutt -s "mutt testemail" <your_email>@gmail.com < testemailtext.txt
Test attachment:
mutt -s "test email with attachment" -a /tmp/cat_pic.png -- <your_email>@gmail.com < testemailtext.txt
great success
[1] I use ~/.muttrc
Last edited: