Jump to content

Sending emails via command line: Difference between revisions

Line 106: Line 106:
This next method is superior when sending longer messages. Instead of using the echo command, we'll store our email header and body information into a text file. Just as in the example above, let's send an email from the hypothetical address '''[email protected]''' to '''[email protected]''' using Gmail's SMTP settings, but without using echo:
This next method is superior when sending longer messages. Instead of using the echo command, we'll store our email header and body information into a text file. Just as in the example above, let's send an email from the hypothetical address '''[email protected]''' to '''[email protected]''' using Gmail's SMTP settings, but without using echo:


  :~# sendmail -v -H "exec openssl s_client -quiet -connect smtp.gmail.com:587 -tls1 -starttls smtp" <span style=color:red>'''</tmp/mail.txt'''</span> -f dziugas.matrosovas@gmail.com -au"[email protected]" -ap"pass"[email protected]
  :~# sendmail -v -H "exec openssl s_client -quiet -connect smtp.gmail.com:587 -tls1 -starttls smtp" <span style=color:red>'''</tmp/mail.txt'''</span> -f senders.email@gmail.com -au"[email protected]" -ap"pass"[email protected]


As you can see, instead of using echo, we're using <span style=color:red>'''</tmp/mail.txt'''</span>, which is the path to the '''mail.txt''' file that stores the email's header and body. This file does not exist in the router, therefore, you should create it yourself. To create a file, use the '''touch''' command:
As you can see, instead of using echo, we're using <span style=color:red>'''</tmp/mail.txt'''</span>, which is the path to the '''mail.txt''' file that stores the email's header and body. This file does not exist in the router, therefore, you should create it yourself. To create a file, use the '''touch''' command:
Anonymous user