Steps:
1. Install mutt: # apt-get install mutt
2. Create the file ".muttrc" in the home directory: $ touch .muttrc
3. Create the directory ".mutt/cache": $ mkdir -p .mutt/cache
4. Edit the file .muttrc with your USERNAME, PASSWORD and REALNAME:
set imap_user = "USERNAME@gmail.com"set imap_pass = "PASSWORD"set smtp_url = "smtp://USERNAME@smtp.gmail.com:587/"set smtp_pass = "PASSWORD"set from = "USERNAME@gmail.com"set realname = "REALNAME"set editor = "nano"set folder = "imaps://imap.gmail.com:993"set spoolfile = "+INBOX"set imap_check_subscribedset hostname = gmail.comset mail_check = 120set timeout = 300set imap_keepalive = 300set postponed = "+[GMail]/Drafts"set record = "+[GMail]/Sent Mail"set header_cache=~/.mutt/cache/headersset message_cachedir=~/.mutt/cache/bodiesset certificate_file=~/.mutt/certificatesset move = noset includeset sort = 'threads'set sort_aux = 'reverse-last-date-received'set auto_tag = yesignore "Authentication-Results:"ignore "DomainKey-Signature:"ignore "DKIM-Signature:"hdr_order Date From To Ccalternative_order text/plain text/html *auto_view text/htmlbind editor complete-querybind editor ^T completebind editor noop macro index,pager y "unset trash\n " "Gmail archive message"macro index,pager d "set trash=\"imaps://imap.googlemail.com/[GMail]/Bin\"\n " "Gmail delete message"macro index,pager gi "=INBOX" "Go to inbox"macro index,pager ga "=[Gmail]/All Mail" "Go to all mail"macro index,pager gs "=[Gmail]/Starred" "Go to starred messages"macro index,pager gd "=[Gmail]/Drafts" "Go to drafts"5. Send a email: $ echo "Hi, how are you?" | mutt -s "subject text" EMAILTOSEND@EMAIL.COM
6. Send a email with attached files: $ echo "Hi, how are you? I attached you a file" | mutt -s "subject text" EMAILTOSEND@EMAIL.COM -a name_file
SEND AN EMAIL WITH PYTHON
import smtplib
GMAIL_USER = 'your_name@gmail.com'
GMAIL_PASS = 'your_password'
SMTP_SERVER = 'smtp.gmail.com'
SMTP_PORT = 587
def send_email(recipient, subject, text):
smtpserver = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.ehlo
smtpserver.login(GMAIL_USER, GMAIL_PASS)
header = 'To:' + recipient + '\n' + 'From: ' + GMAIL_USER
header = header + '\n' + 'Subject:' + subject + '\n'
msg = header + '\n' + text + ' \n\n'
smtpserver.sendmail(GMAIL_USER, recipient, msg)
smtpserver.close()
send_email('destination_email_address', 'sub', 'this is text')