linux
If you’ve ever typed “echo hi | mail user@example.com” from a *nix prompt. then you’re familiar with the unix “mail” command, typically part of GNU Mailutils, which, if not already installed on your linux box, you added via “yum install mailutils” or “apt-get install mailutils.”I just did this myself, after repurposing my 12 year old VPS (my oldest active server!) into a dedicated MTA. It’s not going to host any websites, it’s not going to hold any email list data, it’s not going to have a bunch of other random stuff beyond just being a nice and fast and clean Postfix install that is on a server with a dedicated IP address that has 12 years of solid deliverability history. Truly, there’s value in a good email reputation history.Anyway, so I’m setting up occasional alerts. Some more complex than others, but sometimes just something simple that sends output like “echo
Hey, *nix users! Did you know that you can send email using cURL? If you weren’t aware, cURL “is a computer software project providing a library (libcurl) and command-line tool (curl) for transferring data using various network protocols. The name stands for ‘Client URL’ (wikipedia).” It’s a very handy tool for those of us working in the email security, anti-spam or software-as-a-service space, allowing us to interact with web servers and services to download files and data. I use it quite a bit. But I had no idea that it can speak SMTP! It doesn’t look too difficult, either.Here’s how I tested it myself, composing the command thusly (ignore those goofy quotes at the start and end): curl –ssl-reqd –url ‘smtp://gmail-smtp-in.l.google.com:25’ –mail-from blarfengar@xnnd.com –mail-rcpt nugget@wombatmail.com –upload-file –
Here’s a neat unix/linux email trick: How to get notified via email for SSH logins, courtesy of Tech Republic’s Jack Wallen. And it uses your Gmail account to send the mail, like I offered up back in 2020 (great minds think alike). You don’t NEED to implement that step if your server has a good email sending reputation and history already, but if you don’t — if the server hardly sends any mail at all, you’re not sure if DKIM or DMARC is set up properly, etc., then sending via Gmail is a great way to do it, letting you bypass IP warming, reputation and authentication configuration issues. Anyway, beyond that, the core of the notification setup itself is pretty simple. Click on through to see how it is configured.
Need to export a file from Linux via email? Got uuencode? Do you even remember uuencode? It’s how we used to encode files for file sharing, back before you were born. Because I’m old.Here’s a handy one-liner that will wrap your file up as a UUEncoded attachment and mail it to the address you specify. The email should come through with a properly formatted attachment that you can then download.Just do this (all on one line):% cat file.zip | uuencode file.zip | mail recipient@example.comOr you can get a bit fancier and add a subject line and a proper from address (if your system doesn’t add one already):% cat file.zip | uuencode file.zip | mail -s “Export of file.zip” -a “From: Me ” recipient@example.comOr you can do it as part of a shell script, with bits that look something like this:FROM=”Just Me “TO=”recipient@example.com”FILE=”file.zip”cat $FILE | uuencode $FILE mail -s “Export of $FILE attached”…