When the SMTP server is unreachable, the Email Notification plugin logs a connection error like 'Could not connect to SMTP host' and the build fails.
Port 587 with STARTTLS enabled (useStartTls=true) and SSL disabled (useSsl=false) is the correct setup for SMTP with STARTTLS.
In Jenkins scripted pipeline, currentBuild.currentResult holds the build status. Using it in the if condition correctly triggers email on failure.
The warning 'No recipients specified for email notification' means the plugin has no target addresses, so it skips sending emails silently.
Using Jenkins Credentials plugin to store SMTP credentials keeps them encrypted and avoids exposing passwords in job configs or logs.
