#format wiki
#language en

= SMTP Simple mail transfer protocol =

== SMTP / Email spoof tests ==
 * [[https://emailspooftest.com/]]
 * Basic server test 2023 - [[https://ssl-tools.net/mailservers]]
 * Test mail - [[http://www.allaboutspam.com/email-server-test/]] -> Send mail to "test @ allaboutspam.com"
 * (./) 2023-06 [[http://mail-server-test.online-domain-tools.com/]]
 * Website check - [[https://www.amberloom.com/]]
 * [[https://internet.nl/test-mail/]]
 * (./) 2023-06 send test email to server [[https://www.wormly.com/test-smtp-server/]]
 * [[https://mxtoolbox.com/emailhealth]]
 * (./) 2023-06 apply to remove IP from [[https://www.spamrats.com/]]

== Check / Removal spam lists ==
 * (./) 2023-06 Fixed [[https://spfbl.net/en/delist/]]  ==> check [[https://matrix.spfbl.net/103.252.118.112]]
 *  rbl.rbldns.ru

== Verify smtp ssl/tls certificate ==

 * {{{
printf 'quit\n' | openssl s_client -connect mail.example.com:25 -starttls smtp | openssl x509 -dates -noout

printf 'quit\n' | openssl s_client -connect smtp.vigor.nz:25 -starttls smtp | openssl x509 -dates -text | grep "verify\|notAfter=\|vigor\|SAN\|DNS:\|Subject Alternative Name:"

openssl s_client -connect smtp.azurecomm.net:587 -starttls smtp 
}}}

 * Connect and login {{{
$ echo -e "My@Email.com" | base64 -d ;  echo
$ echo -e "MyPasswd" | base64 -d ;  echo
openssl s_client -connect smtp.azurecomm.net:587 -starttls smtp -crlf

EHLO

auth login

ei1...xCg==

Tll...bgo=

MAIL FROM:<spam-smtp-test@vigor.nz>

MAIL FROM:<donotreply@8...7.azurecomm.net>

RCPT TO:<me@gmail.com> NOTIFY=success,failure
DATA
Subject: Test through telnet.
<nl>
This is the msg.
.
QUIT
}}}

Powershell * {{{
$Password = ConvertTo-SecureString -AsPlainText -Force -String 'NYd...cKn'
$Cred = New-Object -TypeName PSCredential -ArgumentList 'communicationservice|5...4|0...1', $Password
Send-MailMessage -From 'TWG Printer <donotreply@8...7.azurecomm.net>' -To 'Me <Me@gmail.com>' -Subject 'Test mail pwsh smtp' -Body 'test' -SmtpServer 'smtp.azurecomm.net' -Port 587 -Credential $Cred -UseSsl
}}

== Debug smtp sasl starttls authentication ==

 * Connect and move to tls protected channel {{{
$ openssl s_client -starttls smtp -crlf -connect vigor.nz:25
ehlo testconnection
auth plain (base64encodedstring)
}}}

 * test sasl (/etc/sasldb2 )with {{{
# sasldblistusers2
# testsaslauthd -u user -p password -f /var/spool/postfix/var/run/saslauthd/mux
}}}

 * add user to sasl {{{
saslpasswd -c -u mail.example.com -a smtpauth test
}}}

 * view postfix smtp logs using journalctl {{{
journalctl -u postfix@-.service  -f
}}}

 * Check tls certificate on smtp server {{{
# echo "quit" | openssl s_client -starttls smtp -crlf -connect <smtp.host>:25 | openssl x509 -noout -text | grep DNS:
}}}

...