from .mailaddress import MailAddress
-__version__ = '0.2.3'
+__version__ = '0.2.4'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
mail_group = self.arg_parser.add_argument_group(_('Mailing options'))
+ mail_from = MailConfiguration.default_mail_from_complete
+ mail_method = MailConfiguration.default_mail_method
+ mail_server = MailConfiguration.default_mail_server
+ smtp_port = MailConfiguration.default_smtp_port
+
+ if self.cfg:
+ mail_from = self.cfg.mail_from
+ mail_method = self.cfg.mail_method
+ mail_server = self.cfg.mail_server
+ smtp_port = self.cfg.smtp_port
+
mail_group.add_argument(
'--from', '--mail-from',
metavar=_("ADDRESS"), dest="mail_from",
help=_(
"Sender mail address for mails generated by this script. "
- "Default: {!r}").format(self.cfg.mail_from),
+ "Default: {!r}").format(mail_from),
)
mail_group.add_argument(
help=_(
"Method for sending the mails generated by this script. "
"Valid values: {v}, default: {d!r}.").format(
- v=method_list, d=self.cfg.mail_method)
+ v=method_list, d=mail_method)
)
mail_group.add_argument(
metavar=_("SERVER"), dest="mail_server",
help=_(
"Mail server for submitting generated by this script if "
- "the mail method of this script is 'smtp'. Default: {!r}.").format(
- self.cfg.mail_server)
+ "the mail method of this script is 'smtp'. Default: {!r}.").format(mail_server)
)
mail_group.add_argument(
action=PortOptionAction,
help=_(
"The port to use for submitting generated by this script if "
- "the mail method of this script is 'smtp'. Default: {}.").format(
- self.cfg.smtp_port)
+ "the mail method of this script is 'smtp'. Default: {}.").format(smtp_port)
)
# -------------------------------------------------------------------------
from .xlate import XLATOR
-__version__ = '0.1.5'
+__version__ = '0.1.6'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
default_reply_to = 'solution@pixelpark.com'
default_mail_server = 'localhost'
+ default_smtp_port = 25
current_user_name = pwd.getpwuid(os.getuid()).pw_name
current_user_gecos = pwd.getpwuid(os.getuid()).pw_gecos
default_mail_from = MailAddress(current_user_name, socket.getfqdn())
+ default_mail_from_complete = '{n} <{m}>'.format(n=current_user_gecos, m=default_mail_from)
valid_mail_methods = VALID_MAIL_METHODS
+ default_mail_method = 'smtp'
whitespace_re = re.compile(r'(?:[,;]+|\s*[,;]*\s+)+')
add_stems.append('mail')
self.mail_recipients = copy.copy(self.default_mail_recipients)
- self.mail_from = '{n} <{m}>'.format(
- n=self.current_user_gecos, m=self.default_mail_from)
+ self.mail_from = self.default_mail_from_complete
self.mail_cc = copy.copy(self.default_mail_cc)
self.reply_to = self.default_reply_to
- self.mail_method = 'smtp'
+ self.mail_method = default_mail_method
self.mail_server = self.default_mail_server
- self.smtp_port = 25
+ self.smtp_port = self.default_smtp_port
self._mail_cc_configured = False
super(MailConfiguration, self).__init__(
res['default_mail_cc'] = self.default_mail_cc
res['default_reply_to'] = self.default_reply_to
res['default_mail_server'] = self.default_mail_server
+ res['default_smtp_port'] = self.default_smtp_port
res['current_user_name'] = self.current_user_name
res['current_user_gecos'] = self.current_user_gecos
res['default_mail_from'] = self.default_mail_from
+ res['default_mail_from_complete'] = self.default_mail_from_complete
+ res['default_mail_method'] = self.default_mail_method
return res