SoFunction
Updated on 2025-04-11

Windows server server uses the blat command line to send emails

You can use the mail command to send emails under the command line of the Linux platform. There is no built-in command on the Windows platform, but you can use the open source blat, and its official homepage is /. blat is an open source free tool and is very useful. With full functions, this mature tool should be preferred over the software of unknown authors of some websites.

The method of sending emails using the blat command line for Windows server is as follows:

Download blat

Download the file first, download the address: /projects/blat/files/Blat%20Full%20Version/64%20bit%20versions/

bat command line example

After decompression, just need to enter this folder and run the following script for blat test. The email body must be read using a predefined file, as shown below

@echo off
:: blattInstallation Directory
set _extendDir=E:\myFiles\process_monitor
cd /d %_extendDir%
:: Setting up messages
:: title
set s="chnnel tomcat is restart"
:: Content of the text,Pre-edited with text,It will be displayed in the email body
set mail=%_extendDir%\
:: Recipient
set t=3434677021@
:: Sender
set f=process_monitor@
:: 163Mail Server Authorization Code
set pw=IM5IEsWE5alHGJTF
:: Send a message
blat %mail% -s %s% -to %t% -server smtp. -f %f% -u %f% -pw %pw%

pause

Remark

Some mail servers need to be verified. For example, qq mailbox, use the following command to configure blat:

blat -install  123456@ -u 123456 -pw mypassword

If you configure the number of retry times, such as retrying 3 times, you need to execute the following command. This configuration is done directly in the folder and does not need to be added to the bat file every time, otherwise it will be very slow:

blat -install smtp. usr@ 3 25

Summarize

This article introduces how to use Blat, a Windows command line tool, to achieve regular email sending. By configuring the SMTP server, creating text files containing mail content, combining batch (bat) scripts and Windows scheduled tasks, you can set the timed sending of mail with attachments.

This is the article about sending emails using the blat command line in Windows server. For more relevant content on sending emails using blat on Windows platform, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!