In this example we will work with gmail account. We must go click the gear icon in gmail page, go to Settings
, go to the tab Forwarding POP/IMAP
, and click the Configuration instructions
link in IMAP Access
row.
Then click Enable IMAP
. Note the mail server information and use that information for further settings as shown in the next section.
Before proceeding further visit https://www.google.com/settings/security/lesssecureapps and check Turn on
radio button.
Install mutt
Ubuntu
sudo aptitude insta
ll mutt
sudo apt-get install mutt
Configure Mutt
We need create:
mkdir -p ~/.mutt/cache/headers
mkdir ~/.mutt/cache/bodies
touch ~/.mutt/certificates
A mutt configuration file called muttrc
touch ~/.mutt/muttrc
We modify mutter file:
vim ~/.mutt/muttrc
Add following configurations
set ssl_starttls=yes
set ssl_force_tls=yes
set from = "user@gmail.com"
set realname = "Your name"
set imap_user = "user@gmail.com"
set imap_pass = "password"
set folder = imaps://imap.gmail.com/
set spoolfile = "+INBOX"
set postponed ="+[Gmail]/Drafts"
set header_cache =~/.mutt/cache/headers
set message_cachedir =~/.mutt/cache/bodies
set certificate_file =~/.mutt/certificates
set smtp_url = "smtp://user@smtp.gmail.com:587/"
set smtp_pass = "password"
set move = no
set imap_keepalive = 900
Send a email
Now is ready to start sending emails.
mutt -s "Subject" user@icloud.com < message.txt
And if you want to send an attachment
mutt -s "Subject" user@icloud.com < message.txt -a /tmp/photo.jpg
-s => is the subject
-a => is the attachment
message.txt => is the message itself
This is another way to write the test, having the body in the same line.
echo "body" | mutt -s "Subject" user@icloud.com -a /tmp/photo.png
And you can add those command in any file or script.
Settings
, go to the tab Forwarding POP/IMAP
, and click the Configuration instructions
link in IMAP Access
row.nable IMAP
. Note the mail server information and use that information for further settings as shown in the next section.
Before proceeding further visit https://www.google.com/settings/security/lesssecureapps and check
Turn on
radio button.
Install mutt
Ubuntu
sudo aptitude insta
ll mutt
sudo apt-get install mutt
Configure Mutt
We need create:
mkdir -p ~/.mutt/cache/headers
mkdir ~/.mutt/cache/bodies
touch ~/.mutt/certificates
A mutt configuration file called
muttrc
touch ~/.mutt/muttrc
We modify mutter file:
vim ~/.mutt/muttrc
Add following configurations
set ssl_starttls=yes
set ssl_force_tls=yes
set from = "user@gmail.com"
set realname = "Your name"
set imap_user = "user@gmail.com"
set imap_pass = "password"
set folder = imaps://imap.gmail.com/
set spoolfile = "+INBOX"
set postponed ="+[Gmail]/Drafts"
set header_cache =~/.mutt/cache/headers
set message_cachedir =~/.mutt/cache/bodies
set certificate_file =~/.mutt/certificates
set smtp_url = "smtp://user@smtp.gmail.com:587/"
set smtp_pass = "password"
set move = no
set imap_keepalive = 900
Send a email
Now is ready to start sending emails.
mutt -s "Subject" user@icloud.com < message.txt
And if you want to send an attachment
mutt -s "Subject" user@icloud.com < message.txt -a /tmp/photo.jpg
-s => is the subject
-a => is the attachment
message.txt => is the message itself
This is another way to write the test, having the body in the same line.
echo "body" | mutt -s "Subject" user@icloud.com -a /tmp/photo.png
And you can add those command in any file or script.