Source code for fabtools.require.postfix
"""
Postfix
=======
This module provides high-level tools for managing the Postfix_ email server.
.. _Postfix: http://www.postfix.org/
"""
from fabric.api import *
from fabtools.deb import is_installed, preseed_package, install
from fabtools.require.service import started
[docs]def server(mailname):
"""
Require a Postfix email server.
This makes sure that Postfix is installed and started.
::
from fabtools import require
# Handle incoming email for our domain
require.postfix.server('example.com')
"""
# Ensure the package is installed
if not is_installed('postfix'):
preseed_package('postfix', {
'postfix/main_mailer_type': ('select', 'Internet Site'),
'postfix/mailname': ('string', mailname),
'postfix/destinations': ('string', '%s, localhost.localdomain, localhost ' % mailname),
})
install('postfix')
# Ensure the service is started
started('postfix')