-----自己實測OK-----
使用gmail 來寄信,夾兩個檔,寄給兩個不同domain的人,中文主旨
swaks --from [email protected] --to [email protected],[email protected] --auth --auth-user=XXXXXX --auth-password=XXXXXX -tls --server smtp.gmail.com:587 --header "Subject:test 中文" --attach text.pdf --attach photo.jpg
------原文內容------------
如何用 telnet 來測試 SMTP 已是基本常識了,但 swaks 這工具可以更省力些。
swaks --from [email protected] --to [email protected],[email protected] --auth --auth-user=XXXXXX --auth-password=XXXXXX -tls --server smtp.gmail.com:587 --header "Subject:test 中文" --attach text.pdf --attach photo.jpg
------原文內容------------
執行 swaks 快速測試 SMTP
如何用 telnet 來測試 SMTP 已是基本常識了,但 swaks 這工具可以更省力些。
如何測試SMTP?
telnet 的指令很單純,網路上也很多的教學,但最早怎麼測 SMTP 的文件,應該是這篇 RFC 821 ,說明了telnet之後下什麼指令測試。透過swaks把這些常重覆會用到的語法包裝成下參數的方式來執行。
簡易安裝
swaks 已在Linux裡有現成的套件。
但觀察這套件其實就是只有一個 perl script
快速使用
若沒有指定 from 的話,會用 linux 本身的帳號及主機名稱為 from 來寄測試信:
指定 --from 能指定寄件者名稱,
若把 --server 的參數拿掉,則會自動找收件者的 MX 記錄,再往該 MX 去測試:
指定內容
測試的信件內容預設為 This is a test mailing,若要指定內容可以用這語法指到文字檔:
若要測試寄病毒信件會有什麼結果,可用這樣子的指令:
網管就是希望能用最省力的工具來做測試。
參考資料:
swaks 官網
swaks - Swiss Army Knife SMTP, the all-purpose smtp transaction tester
Testing SMTP servers with SWAKS
telnet 的指令很單純,網路上也很多的教學,但最早怎麼測 SMTP 的文件,應該是這篇 RFC 821 ,說明了telnet之後下什麼指令測試。透過swaks把這些常重覆會用到的語法包裝成下參數的方式來執行。
簡易安裝
swaks 已在Linux裡有現成的套件。
- # pacman -S swaks
- resolving dependencies...
- looking for inter-conflicts...
- Packages (3): perl-net-dns-0.72-2 perl-net-ip-1.26-1 swaks-20130209.0-1
- Total Download Size: 0.34 MiB
- Total Installed Size: 0.91 MiB
- :: Proceed with installation? [Y/n]
- :: Retrieving packages ...
- perl-net-ip-1.26-1-any 24.4 KiB 4.77M/s 00:00 [################################] 100%
- perl-net-dns-0.72-2-x86_64 262.8 KiB 7.55M/s 00:00 [################################] 100%
- swaks-20130209.0-1-any 59.4 KiB 11.6M/s 00:00 [################################] 100%
- (3/3) checking keys in keyring [################################] 100%
- (3/3) checking package integrity [################################] 100%
- (3/3) loading package files [################################] 100%
- (3/3) checking for file conflicts [################################] 100%
- (3/3) checking available disk space [################################] 100%
- (1/3) installing perl-net-ip [################################] 100%
- (2/3) installing perl-net-dns [################################] 100%
- (3/3) installing swaks [################################] 100%
# pacman -S swaks resolving dependencies... looking for inter-conflicts... Packages (3): perl-net-dns-0.72-2 perl-net-ip-1.26-1 swaks-20130209.0-1 Total Download Size: 0.34 MiB Total Installed Size: 0.91 MiB :: Proceed with installation? [Y/n] :: Retrieving packages ... perl-net-ip-1.26-1-any 24.4 KiB 4.77M/s 00:00 [################################] 100% perl-net-dns-0.72-2-x86_64 262.8 KiB 7.55M/s 00:00 [################################] 100% swaks-20130209.0-1-any 59.4 KiB 11.6M/s 00:00 [################################] 100% (3/3) checking keys in keyring [################################] 100% (3/3) checking package integrity [################################] 100% (3/3) loading package files [################################] 100% (3/3) checking for file conflicts [################################] 100% (3/3) checking available disk space [################################] 100% (1/3) installing perl-net-ip [################################] 100% (2/3) installing perl-net-dns [################################] 100% (3/3) installing swaks [################################] 100%
但觀察這套件其實就是只有一個 perl script
快速使用
若沒有指定 from 的話,會用 linux 本身的帳號及主機名稱為 from 來寄測試信:
- $ swaks --to [email protected] --server mycompany.com
- === Trying mycompany.com:25...
- === Connected to mycompany.com.
- <- 220 mycompany.com ESMTP Postfix
- -> EHLO AP
- <- 250-mycompany.com
- <- 250-PIPELINING
- <- 250-SIZE 10240000
- <- 250-VRFY
- <- 250-ETRN
- <- 250-ENHANCEDSTATUSCODES
- <- 250-8BITMIME
- <- 250 DSN
- -> MAIL FROM:<singernew@ithelp>
- <- 250 2.1.0 Ok
- -> RCPT TO:<[email protected]>
- <** 454 4.7.1 <[email protected]>: Relay access denied
- -> QUIT
- <- 221 2.0.0 Bye
- === Connection closed with remote host.
$ swaks --to [email protected] --server mycompany.com === Trying mycompany.com:25... === Connected to mycompany.com. <- 220 mycompany.com ESMTP Postfix -> EHLO AP <- 250-mycompany.com <- 250-PIPELINING <- 250-SIZE 10240000 <- 250-VRFY <- 250-ETRN <- 250-ENHANCEDSTATUSCODES <- 250-8BITMIME <- 250 DSN -> MAIL FROM:<singernew@ithelp> <- 250 2.1.0 Ok -> RCPT TO:<[email protected]> <** 454 4.7.1 <[email protected]>: Relay access denied -> QUIT <- 221 2.0.0 Bye === Connection closed with remote host.
指定 --from 能指定寄件者名稱,
- $ swaks --from [email protected] --to [email protected] --helo=unqualified --server othercompany.com
- === Trying othercompany.com:25...
- === Connected to othercompany.com.
- <- 220 othercompany.com ESMTP Postfix
- -> EHLO unqualified
- <- 250-othercompany.com
- <- 250-PIPELINING
- <- 250-SIZE 10240000
- <- 250-VRFY
- <- 250-ETRN
- <- 250-ENHANCEDSTATUSCODES
- <- 250-8BITMIME
- <- 250 DSN
- -> MAIL FROM:<[email protected]>
- <- 250 2.1.0 Ok
- -> RCPT TO:<[email protected]>
- <- 250 2.1.5 Ok
- -> DATA
- <- 354 End data with <CR><LF>.<CR><LF>
- -> Date: Sat, 12 Oct 2013 07:34:49 +0800
- -> To: [email protected]
- -> From: [email protected]
- -> Subject: test Sat, 12 Oct 2013 07:34:49 +0800
- -> X-Mailer: swaks v20130209.0 jetmore.org/john/code/swaks/
- ->
- -> This is a test mailing
- ->
- -> .
- <- 250 2.0.0 Ok: queued as 964DB49A53
- -> QUIT
- <- 221 2.0.0 Bye
- === Connection closed with remote host.
$ swaks --from [email protected] --to [email protected] --helo=unqualified --server othercompany.com === Trying othercompany.com:25... === Connected to othercompany.com. <- 220 othercompany.com ESMTP Postfix -> EHLO unqualified <- 250-othercompany.com <- 250-PIPELINING <- 250-SIZE 10240000 <- 250-VRFY <- 250-ETRN <- 250-ENHANCEDSTATUSCODES <- 250-8BITMIME <- 250 DSN -> MAIL FROM:<[email protected]> <- 250 2.1.0 Ok -> RCPT TO:<[email protected]> <- 250 2.1.5 Ok -> DATA <- 354 End data with <CR><LF>.<CR><LF> -> Date: Sat, 12 Oct 2013 07:34:49 +0800 -> To: [email protected] -> From: [email protected] -> Subject: test Sat, 12 Oct 2013 07:34:49 +0800 -> X-Mailer: swaks v20130209.0 jetmore.org/john/code/swaks/ -> -> This is a test mailing -> -> . <- 250 2.0.0 Ok: queued as 964DB49A53 -> QUIT <- 221 2.0.0 Bye === Connection closed with remote host.
若把 --server 的參數拿掉,則會自動找收件者的 MX 記錄,再往該 MX 去測試:
- $ swaks --from singernew@mycompany --to [email protected] --helo=unqualified
- === Trying nopam.othercompany.com:25...
- === Connected to nopam.othercompany.com.
- <- 220 nopam.othercompany.com SW-Nopam+ ****
- -> EHLO unqualified
- <- 250-nopam.othercompany.com
- <- 250-PIPELINING
- <- 250-SIZE 209915200
$ swaks --from singernew@mycompany --to [email protected] --helo=unqualified === Trying nopam.othercompany.com:25... === Connected to nopam.othercompany.com. <- 220 nopam.othercompany.com SW-Nopam+ **** -> EHLO unqualified <- 250-nopam.othercompany.com <- 250-PIPELINING <- 250-SIZE 209915200 ...
指定內容
測試的信件內容預設為 This is a test mailing,若要指定內容可以用這語法指到文字檔:
- --body /path/to/gtube/file
--body /path/to/gtube/file
若要測試寄病毒信件會有什麼結果,可用這樣子的指令:
- swaks -t [email protected] --attach - --server test-server.example.com --suppress-data </path/to/eicar.txt
swaks -t [email protected] --attach - --server test-server.example.com --suppress-data </path/to/eicar.txt
網管就是希望能用最省力的工具來做測試。
參考資料:
swaks 官網
swaks - Swiss Army Knife SMTP, the all-purpose smtp transaction tester
Testing SMTP servers with SWAKS
從 Evernote 傳送記事 |
0 意見:
張貼留言