Skip to content

Commit

Permalink
Option to disable automatic sending entirely.
Browse files Browse the repository at this point in the history
  • Loading branch information
venkytv committed Apr 19, 2015
1 parent d3af1be commit a6164d5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ If the watcher is disabled, msmtp-offline will only attempt to flush any queued
messages the next time you send an email. Of course, you can always use
`msmtp-queue` to flush queued mails manually.

If you want to disable connection tests entirely and hold all email until they
are flushed manually, use the `+forcequeue` option or the `FORCE_QUEUE`
environment variable.
```
/path/to/msmtp-offline +forcequeue <any-msmtp-options>
FORCE_QUEUE=1 /path/to/msmtp-offline <any-msmtp-options>
```

__IMPORTANT__: msmtp-offline options (starting with '+') need to be specified *before* any `msmtp` options.

#### Known Issues
Expand Down
21 changes: 14 additions & 7 deletions msmtp-offline
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ QFLUSH_INTERVAL = 30

$NO_WATCHER = ENV['NO_WATCHER'] || false
$FORK_SEND = ENV['FORK_SEND'] || false
$FORCE_QUEUE = ENV['FORCE_QUEUE'] || false

$logger = Logger.new(LOGFILE)
$logger.level = (ENV['DEBUG'] ? Logger::DEBUG : Logger::INFO)
Expand Down Expand Up @@ -292,7 +293,9 @@ else
# Consume msmtp-offline parameters (with a '+' prefix)
while (ARGV.first.start_with?('+'))
arg = ARGV.shift
if (arg == '+fork')
if (arg == '+forcequeue')
$FORCE_QUEUE = true
elsif (arg == '+fork')
$FORK_SEND = true
elsif (arg == '+nowatcher')
$NO_WATCHER = true
Expand Down Expand Up @@ -325,13 +328,17 @@ else
end
FileUtils.mv qtmpfile, qcommfile

(host, port) = smtp_host_port(ARGV)
if accessible?(host, port)
launch('Sending email', Proc.new { launch_sender(qfilebase) })
if $FORCE_QUEUE
$logger.info { "Not attempting to deliver. Queueing message: #{qfilebase}" }
else
$logger.info { "Server inaccessible (#{host}:#{port}). Queueing message: #{qfilebase}" }
unless $NO_WATCHER
launch('Starting watcher', Proc.new { launch_watcher })
(host, port) = smtp_host_port(ARGV)
if accessible?(host, port)
launch('Sending email', Proc.new { launch_sender(qfilebase) })
else
$logger.info { "Server inaccessible (#{host}:#{port}). Queueing message: #{qfilebase}" }
unless $NO_WATCHER
launch('Starting watcher', Proc.new { launch_watcher })
end
end
end
end

0 comments on commit a6164d5

Please sign in to comment.