Return values indicate the success or failure

Upon finishing email sending procedure, Command line email utility returns errorlevel value (exit code) which indicates whether email was sent without any errors or there was a warning (partial data incompability) or even failure to deliver the message to SMTP server.

Errorlevel values returned, can be used in conditional processing in batch programs.

IF / ELSE command syntax:
  • if [not] errorlevel number command [else expression]
  • if errorlevel number command
  • if errorlevel number command else expression
  • if not errorlevel number command
  • if not errorlevel number command else expression

See below on how to use errorlevels for either getting more control over email sending process in batch files or ensuring a successful task completion.

Example of simple batch script:

@echo off

febootimail -FROM -TO -MSG "This message is sent from Windows batch file."

if not errorlevel 5 goto end
echo Couldn't connect to server. Trying again...
goto begin

echo End of batch program.

Full list of errorlevels returned by febootimail:

ErrorlevelCode description
errorlevel 0No error.
errorlevel 1Error opening file.
errorlevel 2Error reading file.
errorlevel 4Couldn't send message: server response (additional error information may be shown).
errorlevel 5Couldn't connect to server (additional detailed error information may be shown).
errorlevel 6Fields TO (or CC / BCC) and FROM are required.
errorlevel 7Failed to initialize the Windows Sockets.
errorlevel 8MFC initialization failed.
errorlevel 9Invalid port number. Valid ports: 0-65535.
errorlevel 10File: "file specified" too big to fit in memory.
errorlevel 16Failed to prepare email for sending.
errorlevel 17Couldn't save EML file to disk.
errorlevel 18TO parameter required when using SPLIT / TOEACH parameter.

A warning code (in the grid below) is returned only if there are no errorlevels (1-10, 16-18). The email can be sent with some warnings.

Warning codeWarning description
errorlevel 11Warning: Unknown parameter.
errorlevel 12Warning: Bad IMG tag, image skipped.
errorlevel 13Warning: Can't open image file: "file specified".
errorlevel 14Warning: Maximum pictures count of n reached.
errorlevel 15Warning: Can't open file: "file specified".
errorlevel 19Warning: Missing parameter after "specified" command.
errorlevel 20Warning: STARTTLS and SSL parameters are mutually exclusive.

Other messages without errorlevel:

No errorlevelMessage description
-There was an error accessing registry. Administrator rights might be necessary.
-Warning: Failed to connect to update server.
-Warning: Can't open log file.
-Warning: Can't write log file.
-There was error(s) while sending message.
-e-mail(s) sent with some warnings.
-SPLIT / TOEACH parameter ignored when saving EML file.

Example of more advanced batch file script where errorlevel values are used as defined variables:

@echo off

febootimail -FROM -TO -MSG "This is second email message"

:: Perform conditional processing...
if %errorlevel% GTR 2 goto other
goto label%errorlevel%

echo Program had return code 0... No error.
goto end

echo Program had return code 1... Error opening file.
goto end

echo Program had return code 2... Error reading file.
goto end

echo Program had return code value larger than 2.

echo End of batch file script.
Additional notes and resources:

If you have any questions, please do not hesitate to contact our support team.

© 2001–2019 Febooti Ltd.