How to send base64 encoded emails from a Linux console for antispam testing?
Matthew Whittaker
Co-founder & CTO, Suped
Published 1 May 2025
Updated 18 Aug 2025
6 min read
Sending Base64 encoded emails directly from a Linux console can be a powerful method for testing how antispam filters behave. It allows for precise control over email content and headers, which is crucial when trying to pinpoint why certain messages might be flagged as spam or caught by a blocklist (or blacklist). This approach is particularly useful for email deliverability professionals and system administrators who need to simulate various email scenarios for diagnostic purposes.
Understanding how different encoding schemes, including Base64, influence spam filter scores is important. Sometimes, the encoding itself, rather than the content, can trigger a spam filter. By sending controlled Base64 messages, you can isolate these factors and see if filters are reacting to the encoding presence or the actual encoded data.
This detailed approach can reveal subtle issues that might otherwise go unnoticed. It’s an effective way to conduct controlled experiments to ensure your legitimate emails avoid the spam folder and reach the inbox reliably. Whether you are dealing with transactional emails or bulk campaigns, knowing how to manipulate and test encoding can significantly improve your overall email deliverability.
The role of base64 in email
Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string format. In the context of email, it's primarily used to transmit non-ASCII data, such as images, audio, or other binary attachments, within the plain text nature of email protocols. It ensures that binary content is not corrupted during transmission through systems that might only handle 7-bit ASCII characters.
Antispam systems often analyze Base64 encoded parts of an email, not just for the content itself, but also for specific patterns or anomalies that might indicate malicious activity or obfuscated spam. For example, an email body consisting entirely of Base64 encoded text, especially when it's unexpected for the message type (e.g., a simple plain text email), can sometimes raise red flags. This is why testing with such emails helps understand how filters react.
It's important to differentiate between content encoding and authentication encoding. While we're focusing on Base64 encoding for email body content, Base64 is also used for encoding SMTP authentication credentials, like passwords, before transmission. These are distinct uses, and spam filters primarily care about the content encoding for detecting malicious payloads or obfuscated spam.
Content encoding impact
Increased size: Base64 encoding typically increases data size by about 33%, which can make larger emails seem suspicious if not justified by attachments.
Obfuscation: Spammers use Base64 to hide malicious content or evade text-based filters, leading antispam systems to flag such patterns.
Content type mismatch: If a simple plain text email is unexpectedly Base64 encoded, it may trigger suspicion due to a mismatch between declared content and actual encoding.
Encoding and sending from Linux
To send a Base64 encoded email from your Linux console, you'll need to prepare the email content, encode it, and then send it via an SMTP client. The swaks (Swiss Army Knife for SMTP) tool is excellent for this due to its flexibility. Alternatively, you can manually encode content using the base64 command and then construct the email manually.
First, prepare your email body content in a file. Let's say you want to test how an antispam system handles a suspicious string, like a portion of the EICAR test file, encoded in Base64. You would place this content in a text file, for instance, email_body.txt.
Now, you can Base64 encode the content of email_body.txt. The base64 command is straightforward. If you want to integrate this directly into swaks, swaks has options for this. For a manual approach, you'd output the Base64 string to a new file, say encoded_body.txt.
Base64 encoding the email bodybash
base64 email_body.txt > encoded_body.txt
Using swaks to send this Base64 encoded email is efficient. The --body-file option combined with --body-encoding B (for Base64) tells swaks to read the file and encode its content. Note that swaks also has a --body-base64 option, as described in its official documentation. This command will construct a MIME email with the specified encoding.
Once you've sent your Base64 encoded test email, the next critical step is to analyze how the receiving antispam system processes it. This involves checking the email's final destination, whether it lands in the inbox or the spam folder. You should also examine the email headers for any added spam scores or flags from the filtering system. Tools like SpamAssassin often add X-Spam-Status or X-Spam-Report headers that detail why an email was scored in a certain way.
Pay close attention to rules related to MIME encoding, hidden content, or suspicious Base64 payloads. Some filters might have specific rules designed to catch unusual Base64 patterns, even if the decoded content isn't explicitly malicious. This kind of testing helps you understand if your legitimate content, when encoded, might inadvertently trigger a blocklist (or blacklist) or a spam flag.
This hands-on testing complements broader email deliverability strategies, such as maintaining a good sending reputation and ensuring proper authentication with SPF, DKIM, and DMARC. By understanding the nuances of how Base64 encoding impacts filtering, you can fine-tune your email sending practices and content to improve inbox placement. For more insights on this topic, review our guide on whether Base64 encoding impacts spam filter scores.
Positive indicators
Inbox delivery: The email lands directly in the recipient's inbox.
Low spam score: Headers indicate a low or acceptable spam score, with no Base64-specific flags.
Expected decoding: The email client correctly decodes the Base64 content and displays it as intended.
Negative indicators
Spam folder placement: The email is delivered to the spam or junk folder.
High spam score: Headers reveal a high spam score, often with specific rules triggered by Base64 content.
Blocking or rejection: The email is entirely rejected by the receiving server due to content filtering, sometimes leading to a hard bounce.
Key takeaways for effective testing
Mastering the ability to send Base64 encoded emails from a Linux console equips you with a powerful tool for advanced antispam testing. This technique is invaluable for diagnosing complex deliverability challenges and optimizing your email sending infrastructure. By systematically testing how different types of encoded content are perceived by various filters, you can proactively address potential issues.
Regularly testing your email streams with controlled Base64 messages can help you understand the specific sensitivities of popular antispam solutions. This granular insight allows you to refine your content creation and sending practices, ultimately leading to higher inbox placement rates and a stronger sender reputation. It's a key practice for anyone serious about email deliverability.
Incorporating these console-based testing methods into your routine can provide immediate feedback on changes in email content or server configurations. This level of control is often missing from automated tools, making direct Linux console testing a crucial complement for comprehensive email deliverability assurance.
Views from the trenches
Best practices
Always specify the correct MIME type for Base64 encoded content.
Use standard Base64 encoding tools available in Linux for consistency.
Regularly monitor antispam logs for detailed insights into filtering decisions.
Combine Base64 testing with other deliverability checks like SPF, DKIM, and DMARC verification.
Common pitfalls
Forgetting to declare the Content-Transfer-Encoding header as Base64.
Encoding non-binary content unnecessarily, which can increase spam scores.
Not isolating variables during testing, making it hard to pinpoint issues.
Failing to check if the encoded email is correctly decoded by the recipient's mail client.
Expert tips
Leverage the full capabilities of swaks for highly customizable email testing scenarios.
Automate Base64 email tests using scripts for continuous monitoring.
Simulate various email client environments to check rendering and decoding consistency.
Use test accounts on major ISPs (like Gmail, Outlook) to gauge real-world deliverability.
Expert view
Expert from Email Geeks says that Swaks is a capable tool for sending Base64 encoded email.
July 29, 2019 - Email Geeks
Marketer view
Marketer from Email Geeks says that the standard /bin/base64 command can also be used for encoding.