Ask me six months ago and I would have no idea about this, but alas, I’ve taken a vacation through the depths of hell and come bearing fruits.
This is an email template that you can use to communicate directly to an SMTP server. It’s great for testing odd things with email servers or submitting test emails.
------------------------------------------------------------
INSECURE SMTP SUBMISSION TEMPLATE
------------------------------------------------------------
EHLO arch.local
MAIL FROM:<test@arch.local>
RCPT TO:<sa@arch.local>
DATA
Date: 5 Mar 2021 16:10:00 -0600
Subject: TEST EMAIL
Message-ID: <test01-000000001@arch.local>
From: Tester <test@arch.local>
To: sa@arch.local
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="=-ntScMdyIG9JCYPQb5fci"
--=-ntScMdyIG9JCYPQb5fci
Content-Type: text/plain; charset="utf-8"
test content
--=-ntScMdyIG9JCYPQb5fci
Content-Type: text/html; charset="utf-8"
<html><body>test content</body></html>
--=-ntScMdyIG9JCYPQb5fci--
.
quit
------------------------------------------------------------
Notes:
- The domain after EHLO should be who you are sending from.
- FROM and TO fields are self-explanatory, but if you are sending to a domain that the SMTP server cannot directly handle, you will likely need special relay privileges (e.g. you need to send login/submission commands). Make sure the MIME fields (From/To) match the protocol fields (MAIL FROM/RCPT TO).
- Message-ID is simply a unique string. Give it whatever prefix and increment it for each test.
- Trailing domain should match your domain. Some servers may be picky about what you put in the date field.
- You can paste this right into telnet for some servers. Others might be picky and force you to wait for responses before sending more data.
Example sending
Look up MX servers for gmail:
Connect to one…
Try and fail, because gmail is picky (for good reasons probably).
It worked better when connecting from an external VPS (with dedicated IP and PTR record), and I had to input the protocol bits line by line:
Tada! Spoofed spam mail!
Spam test
The above talks about a scalpel, but you’re looking for a sledgehammer. Not to worry, I needed this too. This will send 10000 emails containing random garbage. Have fun. :)
for( $i = 0; $i -lt 10000; $i++ ) {
$content = -join ((65..90) + (97..122) | Get-Random -Count 2000 | % {[char]$_})
Send-MailMessage -smtpserver mail.arch.local -from sa@arch.local -to john@arch.local `
-subject "Test message # $i" -body "Content sample $i $content"
}