Jump to content

Sending emails via command line: Difference between revisions

Line 75: Line 75:


* '''echo''' - prints the specified arguments to stdout
* '''echo''' - prints the specified arguments to stdout
* <span style=color:green>'''-e'''</span> - makes the echo command interpret backslash escapes (<span style=color:red>'''\n'''</span> in this case)
* <span style=color:green>'''-e'''</span> - makes the echo command interpret backslash escapes (<span style=color:red>'''\n'''</span> in this case)
* <span style=color:red>'''\n'''</span> - the end line symbol, i.e., it indicates that the following text begins in another line. The <span style=color:red>'''\n'''</span> part itself is not interpreted as part of the text if the '''<span style=color:green>'''-e'''</span>''' parameter is specified.


* <span style=color:red>'''\n'''</span> - the end line symbol, i.e., it indicates that the following text begins in another line. The </span><span style=color:red>\n</span> part itself is not interpreted as part of the text if '''<span style=color:green>-e</span>''' is specified.
The text highlighted in blue specifies the email's header information (excluding the recipient's address) and body of text. In our case it represents this:
 
The text highlighted in blue specifies the mail's header information (excluding the recipient's address) and body. In our case it represents this:


  '''Subject''': <span style=color:blue>Test</span>
  '''Subject''': <span style=color:blue>Test</span>
Line 89: Line 87:
  JustTesting</span>  
  JustTesting</span>  


So, in short, the part beginning with '''echo''' and ending just before the column ('''|''') represents the email's header and body of text. Now lets The next part (after the column  
So, in short, the part beginning with '''echo''' and ending just before the column ('''|''') represents the email's header and body of text. Now lets The next part (beginning after the column):
 
'''sendmail <span style=color:green>-v -H</span> "<span style=color:blue>exec openssl s_client -quiet -connect smtp.gmail.com:587 -tls1 -starttls smtp</span>" <span style=color:purple>-au"[email protected]" -ap"senders.email.password"</span> <span style=color:brown>[email protected]</span>'''
 
* <span style=color:green>'''-v'''</span> - verbose mode
* <span style=color:green>'''-H'''</span> - runs connection helper; connection helper allows you to specify additional commands regarding the email (in this case, OpenSSL connection information)
* <span style=color:blue>'''exec openssl s_client -quiet -connect smtp.gmail.com:587 -tls1 -starttls smtp'''</span> - OpenSSL connection information; <span style=color:blue>'''smtp.gmail.com:587'''</span> specifies the SMTP server and port. Replace with email service provider's relevant SMTP settings.
* <span style=color:purple>-au"[email protected]" -ap"senders.email.password"</span> - what follows after <span style=color:purple>'''-au'''</span> inside the quotation marks is the email service's login username and by analogy <span style=color:purple>'''-ap'''</span> specifies the email service's login password (<span style=color:purple>'''[email protected]'''</span> and <span style=color:purple>'''senders.email.password'''</span>, in this case)
* <span style=color:brown>'''[email protected]'''</span> - specifies the recipient's email address
 
sendmail -v -H "exec openssl s_client -quiet -connect smtp.gma
sendmail -v -H "exec openssl s_client -quiet -connect smtp.gma
il.com:587 -tls1 -starttls smtp" <mail.txt -f [email protected] -au"d
il.com:587 -tls1 -starttls smtp" <mail.txt -f [email protected] -au"d