Reference: File SmtpRouter.hst

Purpose

Configuration file "SmtpRouter.hst" contains definitions and rules for sending mails by SMTP in MX mode, e. g. when starting mail transfer by script command "HamSendMailMX".

When sending mails in this MX mode, Hamster tries to detect the mail exchange (MX) servers of the mail recipients and then send the mails directly to the servers found.

Sending mails in MX mode mostly works even without any entries in this file, but it is suggested to at least set a fallback server (see "set fallbackserver" below). This setting makes sure, that the mail is sent out immediately even if no MX servers can be found or none of them accepts the mail.

How to ... deliver mails directly (MX)?

Overview

File Format

File "SmtpRouter.hst" is a plain text file, that is divided into sections, where each section may contain multiple command lines to be executed.

[Section-1]
Command-1
Command-2
Command-3

[Section-2]
Command-1
Command-2

Sequence

All lines in the file are checked from top to down, from the first section found up to the end of the file.

If a command line is preceded with a "=" character and this line is executed, all following lines are ignored.

Comments

All lines starting with a "#" character are treated as comments, i. e. such lines are ignored.

Trailing comments in section or command lines are not supported in this file.

Sections

Each section starts with a "[...]"-header describing the names of dial-up connections (RAS), for which the following lines should be tested. The patterns within "[...]" follow the same rules as the ones described at "Reference: File Scores.hst".

Examples:

[*]
# these lines will always be used, regardless if it is a
# dial-up connection or a direct connection

[]
# these lines will only be used, if no dial-up connection
# exists, e. g. when directly connected by a router

[Provider]
# these lines will only be used, if the name of the current
# dial-up connection (RAS) contains the string "Provider"

Commands

set dnsauto

The "dnsauto" setting determines, if DNS servers should be auto-detected. Valid settings are:

0 don't auto-detect, only use "set dnsserver" setting

1 auto-detect and use found ones as preferred servers

2 auto-detect and use found ones as fallback servers

Values 1 and 2 are the same if no servers are given with "set dnsserver" setting. But if servers are given with "set dnsserver" command, the auto-detected servers are either tried before the given ones (1, preferred) or after the given ones (2, fallback).

Note: Although different techniques are used to detect the DNS servers, it may fail with some Windows versions and/or network infrastructures. If Hamster reports "No DNS server found!" warnings, you have to provide one with "set dnsserver".

Default:

set dnsauto 1

Example:

set dnsauto 2
set dnsserver

The "dnsserver" setting can be used to set the DNS servers to be used when determining the mail exchange servers (MX records) for the recipient of a mail.

Multiple DNS servers can be given by separating them with whitespace (SPACE or TAB characters). Each server can immediately be followed by a colon (":") and a port number, if it does not run on default port number 53.

If you don't know the DNS servers and auto-detecting them does not work, ask your network administrator or your provider for the DNS servers to use.

Default:

set dnsserver ""

Example:

set dnsserver 192.168.0.3 192.168.0.4:9053
set dnstimeout

The "dnstimeout" setting gives the timeout in milliseconds for querying the DNS server for the mail exchange servers (MX records) of recipient's domain.

Default:

set dnstimeout 10000

Example:

set dnstimeout 5000
set fallbackserver

The "fallbackserver" setting gives a SMTP server to use, when no MX servers are found for recipient's domain or if none of the found ones accepted the mail for any reason. The given server has to be one of the remote SMTP servers configured in Hamster.

Default:

set fallbackserver ""

Examples:

set fallbackserver mail.myprovid.er
set fallbackserver mail.provid.er
set fallbackserver mail.provid.er/john
set limitdns

The "limitdns" setting gives the maximum number of DNS servers to query for MX records. A value of 0 disables this limit.

Default:

set limitdns 3

Example:

set limitdns 1
set limitmx

The "limitmx" setting gives the maximum number of MX servers to try to send a mail. A value of 0 disables this limit.

Default:

set limitmx 3

Example:

set limitmx 1
use

A "use" command can select a specific SMTP server based on recipient's domain. This means, that determining of mail exchange servers is turned off and the mail is directly sent to the given server.

First parameter is the SMTP server to use if patterns match. It has to be one of the remote SMTP servers configured in Hamster.

After the server to use, one or more patterns for recipient's domain follow. The patterns work the same way as the ones described at "Reference: File Scores.hst".

Examples:

use mail.myprovid.er {\.myprovid\.er$}
use mail.provid.er thisdoma.in thatdoma.in

Usage examples

Setup fallback server(s)

It's suggested to set a fallback server, that is finally used if sending mails in MX mode fails for any reason:

[*]
set fallbackserver mail.provid.er

If the mail server is only available for a specific dial-up connection (RAS), just note the fallback server in a separate section containing the name of the dial-up connection:

[MyProvider]
set fallbackserver mail.myprovid.er

MX servers don't accept mails - use specific server instead

Some providers do not accept mails sent to their MX servers from dial-up accounts or from within their own network. In such cases, the time consuming search for MX servers and any attempt to send them mails is completely useless.

For known providers or domains, that show this problem, it is therefore better to directly send the mails to a specific SMTP server, that is known to accept them (e. g. the mailserver of your provider).

The following is an example, how this could be done with the "use" command:

["T-Online" "TOSW-internal"]
use smtprelay.t-online.de {t-online\.(de|at|com)$} {t-dialin\.net$} {aol\.com$}

It means: If name of current dial-up connection contains "T-Online" or "TOSW-internal", all mails to "t-online.de", "t-online.at", "t-online.com", "t-dialin.net" and "aol.com" domains should not be sent to the MX servers of these domains but directly to "smtprelay.t-online.de".

[www.elbiah.de Hamster Playground Documentation]