linux_wiki:send_email_via_gmail_smtp_cmd_line

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
linux_wiki:send_email_via_gmail_smtp_cmd_line [2014/11/30 21:39]
billdozor created
linux_wiki:send_email_via_gmail_smtp_cmd_line [2019/05/25 23:50] (current)
Line 1: Line 1:
 ====== Send Email via Gmail SMTP Cmd Line ====== ====== Send Email via Gmail SMTP Cmd Line ======
-Goal: To send an e-mail message from a bash script or command line program. 
  
-Prerequisites +**General Information**
-  Install msmtp +
-  Install mailx+
  
-=== Install msmtp ===+Send an e-mail message from a bash script or command line program. 
 + 
 +**Checklist** 
 +  * Distro(s): Debian/Ubuntu based 
 + 
 +---- 
 + 
 +===== Install msmtp =====
 This package will allow you to configure what gmail account to send from and will connect securely via TLS to the gmail SMTP servers. This package will allow you to configure what gmail account to send from and will connect securely via TLS to the gmail SMTP servers.
  
Line 13: Line 17:
 </code> </code>
  
-=== Install Mailx ===+---- 
 + 
 +===== Install Mailx =====
 Install a simple mail transfer agent to actually prepare the e-mail message. Install a simple mail transfer agent to actually prepare the e-mail message.
  
Line 20: Line 26:
 </code> </code>
  
-=== Configure Gmail Account on MSMTP ===+----
  
-1) Create a file in your home directory called ".smtprc"+===== Configure Gmail Account on MSMTP ===== 
 + 
 +1) Create a file in your home directory called ".msmtprc"
 <code bash> <code bash>
 vim ~/.msmtprc vim ~/.msmtprc
Line 63: Line 71:
 </code> </code>
  
-=== Configure Mailx ===+---- 
 + 
 +===== Configure Mailx =====
 Setup mailx to use msmtp to send e-mail. Setup mailx to use msmtp to send e-mail.
  
Line 77: Line 87:
 </code> </code>
  
-=== Send mail from the command line ===+----
  
-==Interactively==+===== Send mail from the command line =====
  
-<code>+==== Interactively ==== 
 + 
 +<code bash>
 mail -s "Subject Here" address@destination.com mail -s "Subject Here" address@destination.com
 </code> </code>
Line 87: Line 99:
 You will now be able to type in your message. When you want to send it, type ENTER to go to a blank line and then Ctrl+D to end/send. You will now be able to type in your message. When you want to send it, type ENTER to go to a blank line and then Ctrl+D to end/send.
  
-==Auto Messages==+==== Auto Messages ====
 To send an e-mail from a script, you will need to pre-write your message. To send an e-mail from a script, you will need to pre-write your message.
  
 Populate a text file, such as "message.txt" with the e-mail to be sent. Populate a text file, such as "message.txt" with the e-mail to be sent.
 Then, send it like this: Then, send it like this:
-<code>+<code bash>
 mail -s "My Awesome Message Subject" importantperson@cooldomain.com < message.txt mail -s "My Awesome Message Subject" importantperson@cooldomain.com < message.txt
 </code> </code>
  • linux_wiki/send_email_via_gmail_smtp_cmd_line.1417401555.txt.gz
  • Last modified: 2019/05/25 23:50
  • (external edit)