Skip to content

Instantly share code, notes, and snippets.

@hochun836
Last active April 4, 2024 07:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hochun836/59743d46729474f1f09366276975da6b to your computer and use it in GitHub Desktop.
Save hochun836/59743d46729474f1f09366276975da6b to your computer and use it in GitHub Desktop.
# base
smtp (simple mail transfer protocol)
# telnet
telnet <host> // port: 23
telnet <host> <port>
telnet localhost 25 // enter interactive interface
# interactive (with hMailServer)
220 xxx ESMTP // xxx is server name
EHLO yyy // yyy is client domain name (or ex. EHLO HelloWorld)
250-xxx
250-SIZE 20480000
250-AUTH LOGIN
250 HELP
HELP
211 DATA HELO EHLO MAIL NOOP QUIT RCPT RSET SAML TURN VRFY
NOOP
250 OK
VRFY hochun836@gmail.com
502 VRFY disallowed.
RCPT TO: <bbb@bbb.com>
503 must have sender first.
DATA
503 Must have sender and recipient first.
MAIL FROM: <aaa@aaa.com> // MAIL FROM: aaa@aaa.com (ok), MAIL FROM:aaa@aaa.com (ok)
250 OK
MAIL FROM: <ccc@ccc.com>
503 Issue a reset if you want to start over
RSET
250 OK
MAIL FROM: <aaa@aaa.com> // if the mail address doesn't exist in 'Domains', it is considered as a 'external e-mail address', otherwise it is a "local e-mail address"
250 OK
RCPT TO: <bbb@bbb.com> // if the mail address doesn't exist in 'Domains', it is considered as a 'external e-mail address', otherwise it is a "local e-mail address"
530 SMTP authentication is required. // according to MAIL FROM & RCPT TO & 'Require SMTP authentication' (Settings > Advanced > IP Ranges > (mateched high priority) > Require SMTP authentication)
RSET
MAIL FROM: <test@thishost>
250 OK
RCPT TO: <bbb@bbb.com>
250 OK
DATA
354 OK, send.
Subject: Test Mail
From: xxx@aaa.com // the mail address just shows on the mail
To: yyy@bbb.com // the mail address just shows on the mail
// need a empty line
This is a test email sent via Telnet.
. // DATA finish
250 Queued (zzz seconds)
QUIT // close interactive interface
221 goodbye
Connection to host lost.
# interactive command
HELO (Hello)
EHLO (Extended Hello)
NOOP (No Operation)
RSET (Reset)
VRFY (Verify)
# in hMailServer, 530 SMTP authentication is required
AUTH LOGIN
334 VXNlcm5hbWU6 // VXNlcm5hbWU6 is the base64 of Username:
dGVzdEBsb2NhbGhvc3Q= // dGVzdEBsb2NhbGhvc3Q= is the base64 of test@localhost
334 UGFzc3dvcmQ6 // UGFzc3dvcmQ6 is the base64 of Password:
MVFhejJ3c3g= // MVFhejJ3c3g= is the base64 of 1Qaz2wsx
235 authenticated.
=> ref: https://blog.csdn.net/FunchMin/article/details/106958118
=> ref: https://mailtrap.io/blog/smtp-auth/
# in hMailServer, log file
| Settings > Logging
check 'Enabled'
check 'SMTP'
C:\Program Files (x86)\hMailServer\Logs\
# in hMailServer, IP Ranges
| Settings > Advanced > IP Ranges
- Priority
a higher value means higher priority
- Lower ip & Upper ip
for matching smtp client ip
- Require SMTP authentication
if the 'MAIL FROM' mail address doesn't exist in 'Domains', it is considered as a 'external e-mail address', otherwise it is a "local e-mail address"
if the 'RCPT TO' mail address doesn't exist in 'Domains', it is considered as a 'external e-mail address', otherwise it is a "local e-mail address"
'External to external e-mail address' should normally always be selected (if you do not require authentication when external users sends messages through your server, your server will be abused by spammers)
=> ref: https://www.hmailserver.com/documentation/latest/?page=reference_iprange
# in hMailServer, reset administrator password
C:\Program Files (x86)\hMailServer\Bin\hMailServer.INI
[Security]
AdministratorPassword=7cba6767a5489b002c08bdb068cac033 // 7cba6767a5489b002c08bdb068cac033 is the MD5 of 1Qaz2wsx
# in hMailServer, ide vs. server
hMailServer Administrator (ide)
hMailServer (server)
like
SQL Server Management Studio (ide)
SQL Server (server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment