Curl is a command line utility found on most modern Linux distributions used to retrieve content from the internet. However, it can do a lot more than that and supports a plethora of protocols, including TFTP, SFTP, and SMTP.
Sending an Email
Just wanted to check you were able to receive this email, sent over the curl command.
Has it gone into spam?.
" | curl -s --ssl smtp://$SERVER --mail-from $FROM --mail-rcpt $TO --upload-file /dev/stdin --user email@example.com
Enter host password for user 'firstname.lastname@example.org':
Let's see if the email was delivered (nb: the address has been changed to prevent spam)
Securing the credentials
In this example, the
--user field did not specify a password, this results in a prompt. If you don't want to enter it manually, you can either hardcode it somewhere (bad) or use GPG encryption. With GPG, the gpg-agent can be configured to store credentials in memory. This way, you only need to enter the password once. Configuring gpg is out of the scope of this article