Herhangi bir e-posta sunucusuna Relay/Anonymous posta gönderilebiliyor mu diye kontrol eden Powershell scripti.

# =========================== ============================# NAME: SMTPRelayTest.ps1 # AUTHOR: Bekir Yalçın - SiberBlog.org # LINK: http://siberblog.org/index.php/anonymous-smtp-relay-test-script/ # DATE: 04/12/2014 # COMMENT: SMTP Relay Anonymous Test # ========================== =============================Clear $ErrorActionPreference = "SilentlyContinue" $mail = new-object Net.Mail.MailMessage# ==================Write-Host " ╔══════════════════════ ══════════════════════╗" -ForegroundColor Green Write-Host " ║ SMTP Relay Anonymous Test - Bekir Yalçın ║" -ForegroundColor Green Write-Host " ╚══════════════════════ ══════════════════════╝" -ForegroundColor Green Write-Host ""# ==================# Write-Host " Type SMTP Server: " -ForegroundColor Blue -NoNewline $smtpServer = Read-Host -Prompt "SMTP Server (Örn:192.168.1.10) " # Write-Host $smtpServer $smtp = new-object Net.Mail.SmtpClient($smtpServer)# ================== # Write-Host " From - Gönderen E-posta Adres: " -ForegroundColor Blue -NoNewline $mailFrom = Read-Host -Prompt "From - Gönderen (Örn:a@a.a) " # Write-Host $mailFrom Try { $mail.From = $mailfrom } Catch { Write-Host " ERROR (From - Gönderen): " -ForegroundColor Red -NoNewline Write-Warning $_.Exception.Message } # ================== # Write-Host " To - Alan E-posta Adres: " -ForegroundColor Blue -NoNewline $mailTo = Read-Host -Prompt "To - Alan (Örn:b@b.b) " # Write-Host $mailTo Try { $mail.To.Add($mailTo) } Catch { Write-Host " ERROR (To - Alan): " -ForegroundColor Red -NoNewline Write-Warning $_.Exception.Message } # ================== # Write-Host " Subject - Konu: " -ForegroundColor Blue -NoNewline $mailSubject = Read-Host -Prompt "Subject - Konu " # Write-Host $mailSubject Try { $mail.Subject = ($mailsubject) } Catch { Write-Host " ERROR (Subject - Konu): " -ForegroundColor Red -NoNewline Write-Warning $_.Exception.Message } # ================== # Write-Host " Body - Mesajınız: " -ForegroundColor Blue -NoNewline $mailBody = Read-Host -Prompt "Body - Mesajınız " # Write-Host $mailBody Try { $mail.Body = ($mailbody) } Catch { Write-Host " ERROR (Body - Mesajınız): " -ForegroundColor Red -NoNewline Write-Warning $_.Exception.Message } # ================== # SEND - GÖNDER Try { $smtp.Send($mail) } Catch { Write-Host "" Write-Host " ERROR (SEND - GÖNDER): " -ForegroundColor Red -NoNewline Write-Warning $_.Exception.Message Write-Host "" Write-Host " ╔═══════════════════════ ════════════════════════╗" -ForegroundColor Red Write-Host " ║ Mail Sender ERROR - Gönderme BAŞARISIZ ║" -ForegroundColor Red Write-Host " ╚═══════════════════════ ════════════════════════╝" -ForegroundColor Red Write-Host "" Break } # ================== Write-Host "" Write-Host " ╔═══════════════════════ ════════════════════════╗" -ForegroundColor Green Write-Host " ║ Mail Sender Succesfully - Gönderme Başarılı ║" -ForegroundColor Green Write-Host " ╚═══════════════════════ ════════════════════════╝" -ForegroundColor Green Write-Host "" # ================== |
Script download: SMTPRelayTest_v1.rar
Powershell'de script çalıştırma yetkisi Get-ExecutionPolicy komutu ile kontrol edilebilir. Gerekli ise Set-ExecutionPolicy unrestricted komutu çalıştırılır ve Yes seçilir. Daha sonra scriptin bulunduğu dizine gidilir ve çalıştırılır.
Örnek: C:\Users\Administrator\Desktop> .\SMTPRelayTest.ps1

1- SMTP Server adresi isteğe bağlı olarak IP veya domain adı şeklinde girilir.
2- Gönderici bilgisi e-posta adres formatında yazılır. Bu adresin gerçekte var olan bir adres olması gerekli değildir. Örnek: a@a.a veya Anonymous@SiberBlog.net şeklinde girilebilir.
3- Alıcı adres bilgisi girilir. Örnek: TestUser3@bsga.net
NOT: 2. ve 3. maddelerde belirtilen eposta adresi yanlış formatta yazılır ise hata mesajı ile karşılaşılır.
4- Konu girilir, isteğe göre boşta geçilebilir.
5- Mesaj girilir, isteğe göre boş geçilebilir.
6- E-posta gönderimi başarılı ise Gönderme Başarılı şeklinde mesaj alınır.

7- E-posta kutusu kontrol edilir ve gelen mesaj görülür.

8- E-posta sunucusuna erişildi fakat hata ile karşılaşıldı ise hata mesajı ile karşılaşılacaktır. Hata mesajı incelenerek problem hakkında fikir elde edilebilmektedir. Ekran görüntüsünde Client was not authenticated hatası görülmektedir. Bu hata sunucunun kullanıcı adı ve parola girilmeden eposta gönderilemeyeceği bilgisidir. Yani Anonymous eposta gönderme başarısızdır.

9- Son ekrandaki gibi ayrıntısız bir hata mesajla karşılaşılır ise sunucuya veya SMTP porta (TCP 25) erişim problemini göstermektedir.
Betik ile dosya gönderme ihtiyacı sebebiyle yeni versiyon eklenmiştir.
1- Gönderilecek dosya/dosyalar seçilmek üzere pencere açılır. Gönderilecek dosya/dosyalar seçilir ve "Aç" butonuna tıklanır. Dosya gönderilmeyecek ise "İptal" butonuna tıklanır.

2- Gönderilen dosyalar ekranda listelenir.

Script download-1: SMTPRelayTest_v1.rar
Script download-2: SMTPRelayTest_v2.rar
Hiç yorum yok:
Yorum Gönder