3

[Edit: I answered the first half of my issue, so I'll edit this to address the second half.]

/etc/monit/monitrc looks like this:

set mailserver
    smtp.server.net
    port 587
    username "USERNAME"
    password "PASSWORD"
    using tlsv1 with timeout 30 seconds
    using hostname "server.fqdn.com",

    smtp.server2.net
    port 587
    username "USERNAME"
    password "PASSWORD"
    using tlsv1 with timeout 30 seconds
    using hostname "server.fqdn.com"

sudo service monit syntax spits out this:

/etc/monit/monitrc:57: Error: syntax error 'smtp.server2.com'

At first I had the wrong using/with syntax like this:

    using tlsv1
    using hostname "server.fqdn.com"
    with timeout 30 seconds
chmac
  • 977
  • 1
  • 7
  • 16
  • Typical, immediately after posting, I figured out the answer. The with timeout 30 seconds part belongs to the using tlsv1, so the syntax works like this: `using tlsv1 with timeout 30 seconds using hostname "server.fqdn.com"` Can I somehow withdraw the question? – chmac Jan 04 '12 at 16:57
  • Finally worked it out, the `with timeout 30 seconds using hostname "server.fqdn.com"` need to come at the end of all the mailserver definitions, and they apply to them all. When I RTFM more carefully, I spotted my mistake. – chmac Jan 04 '12 at 17:18

1 Answers1

5

Typical, immediately after posting, I figured out the answer.

The with timeout 30 seconds part belongs to the using tlsv1, so the syntax works like this:

The correct config turned out to be this:

set mailserver
    smtp.server.net
    port 587
    username "USERNAME"
    password "PASSWORD"
    using tlsv1
    ,
    smtp.gmail.com
    port 587
    username "USERNAME"
    password "PASSWORD"
    using tlsv1

    with timeout 30 seconds
    using hostname "server.fqdn.com"

The with timeout and using hostname declarations come after all the servers have been listed, and they apply to all mailservers in the list. Took me ages to finally figure that out, but it is in the manual if you look closely. The white spacing is optional.

chmac
  • 977
  • 1
  • 7
  • 16