mirror of https://github.com/caronc/apprise
Reply-To not put in header if not specified (#664)
parent
d1c653fc04
commit
3efb2c6f3e
|
@ -544,10 +544,6 @@ class NotifyEmail(NotifyBase):
|
||||||
'({}) specified.'.format(recipient),
|
'({}) specified.'.format(recipient),
|
||||||
)
|
)
|
||||||
|
|
||||||
if not reply_to:
|
|
||||||
# Add ourselves to the Reply-To directive
|
|
||||||
self.reply_to.add(self.from_addr)
|
|
||||||
|
|
||||||
# Validate recipients (reply-to:) and drop bad ones:
|
# Validate recipients (reply-to:) and drop bad ones:
|
||||||
for recipient in parse_emails(reply_to):
|
for recipient in parse_emails(reply_to):
|
||||||
email = is_email(recipient)
|
email = is_email(recipient)
|
||||||
|
@ -699,10 +695,11 @@ class NotifyEmail(NotifyBase):
|
||||||
(self.names.get(addr, False), addr), charset='utf-8')
|
(self.names.get(addr, False), addr), charset='utf-8')
|
||||||
for addr in bcc]
|
for addr in bcc]
|
||||||
|
|
||||||
# Format our reply-to addresses to support the Name field
|
if reply_to:
|
||||||
reply_to = [formataddr(
|
# Format our reply-to addresses to support the Name field
|
||||||
(self.names.get(addr, False), addr), charset='utf-8')
|
reply_to = [formataddr(
|
||||||
for addr in reply_to]
|
(self.names.get(addr, False), addr), charset='utf-8')
|
||||||
|
for addr in reply_to]
|
||||||
|
|
||||||
except TypeError:
|
except TypeError:
|
||||||
# Python v2.x Support (no charset keyword)
|
# Python v2.x Support (no charset keyword)
|
||||||
|
@ -714,9 +711,11 @@ class NotifyEmail(NotifyBase):
|
||||||
bcc = [formataddr( # pragma: no branch
|
bcc = [formataddr( # pragma: no branch
|
||||||
(self.names.get(addr, False), addr)) for addr in bcc]
|
(self.names.get(addr, False), addr)) for addr in bcc]
|
||||||
|
|
||||||
# Format our reply-to addresses to support the Name field
|
if reply_to:
|
||||||
reply_to = [formataddr( # pragma: no branch
|
# Format our reply-to addresses to support the Name field
|
||||||
(self.names.get(addr, False), addr)) for addr in reply_to]
|
reply_to = [formataddr( # pragma: no branch
|
||||||
|
(self.names.get(addr, False), addr))
|
||||||
|
for addr in reply_to]
|
||||||
|
|
||||||
self.logger.debug(
|
self.logger.debug(
|
||||||
'Email From: {} <{}>'.format(from_name, self.from_addr))
|
'Email From: {} <{}>'.format(from_name, self.from_addr))
|
||||||
|
@ -808,7 +807,8 @@ class NotifyEmail(NotifyBase):
|
||||||
if cc:
|
if cc:
|
||||||
base['Cc'] = ','.join(cc)
|
base['Cc'] = ','.join(cc)
|
||||||
|
|
||||||
base['Reply-To'] = ','.join(reply_to)
|
if reply_to:
|
||||||
|
base['Reply-To'] = ','.join(reply_to)
|
||||||
|
|
||||||
# bind the socket variable to the current namespace
|
# bind the socket variable to the current namespace
|
||||||
socket = None
|
socket = None
|
||||||
|
@ -901,11 +901,13 @@ class NotifyEmail(NotifyBase):
|
||||||
'' if not e not in self.names
|
'' if not e not in self.names
|
||||||
else '{}:'.format(self.names[e]), e) for e in self.bcc])
|
else '{}:'.format(self.names[e]), e) for e in self.bcc])
|
||||||
|
|
||||||
# Handle our Reply-To Addresses
|
if self.reply_to:
|
||||||
params['reply'] = ','.join(
|
# Handle our Reply-To Addresses
|
||||||
['{}{}'.format(
|
params['reply'] = ','.join(
|
||||||
'' if not e not in self.names
|
['{}{}'.format(
|
||||||
else '{}:'.format(self.names[e]), e) for e in self.reply_to])
|
'' if not e not in self.names
|
||||||
|
else '{}:'.format(self.names[e]), e)
|
||||||
|
for e in self.reply_to])
|
||||||
|
|
||||||
# pull email suffix from username (if present)
|
# pull email suffix from username (if present)
|
||||||
user = None if not self.user else self.user.split('@')[0]
|
user = None if not self.user else self.user.split('@')[0]
|
||||||
|
|
|
@ -859,6 +859,8 @@ def test_plugin_email_url_parsing(mock_smtp, mock_smtp_ssl):
|
||||||
# Test that our template over-ride worked
|
# Test that our template over-ride worked
|
||||||
assert 'mode=ssl' in obj.url()
|
assert 'mode=ssl' in obj.url()
|
||||||
assert 'smtp=override.com' in obj.url()
|
assert 'smtp=override.com' in obj.url()
|
||||||
|
# No reply address specified
|
||||||
|
assert 'reply=' not in obj.url()
|
||||||
|
|
||||||
mock_smtp.reset_mock()
|
mock_smtp.reset_mock()
|
||||||
response.reset_mock()
|
response.reset_mock()
|
||||||
|
@ -871,22 +873,30 @@ def test_plugin_email_url_parsing(mock_smtp, mock_smtp_ssl):
|
||||||
obj = Apprise.instantiate(results, suppress_exceptions=False)
|
obj = Apprise.instantiate(results, suppress_exceptions=False)
|
||||||
assert isinstance(obj, plugins.NotifyEmail) is True
|
assert isinstance(obj, plugins.NotifyEmail) is True
|
||||||
assert obj.smtp_host == 'smtp-mail.outlook.com'
|
assert obj.smtp_host == 'smtp-mail.outlook.com'
|
||||||
|
# No entries in the reply_to
|
||||||
|
assert not obj.reply_to
|
||||||
|
|
||||||
results = plugins.NotifyEmail.parse_url(
|
results = plugins.NotifyEmail.parse_url(
|
||||||
'mailtos://user:pass123@outlook.com.au')
|
'mailtos://user:pass123@outlook.com.au')
|
||||||
obj = Apprise.instantiate(results, suppress_exceptions=False)
|
obj = Apprise.instantiate(results, suppress_exceptions=False)
|
||||||
assert isinstance(obj, plugins.NotifyEmail) is True
|
assert isinstance(obj, plugins.NotifyEmail) is True
|
||||||
assert obj.smtp_host == 'smtp-mail.outlook.com'
|
assert obj.smtp_host == 'smtp-mail.outlook.com'
|
||||||
|
# No entries in the reply_to
|
||||||
|
assert not obj.reply_to
|
||||||
|
|
||||||
results = plugins.NotifyEmail.parse_url(
|
results = plugins.NotifyEmail.parse_url(
|
||||||
'mailtos://user:pass123@live.com')
|
'mailtos://user:pass123@live.com')
|
||||||
obj = Apprise.instantiate(results, suppress_exceptions=False)
|
obj = Apprise.instantiate(results, suppress_exceptions=False)
|
||||||
assert isinstance(obj, plugins.NotifyEmail) is True
|
assert isinstance(obj, plugins.NotifyEmail) is True
|
||||||
|
# No entries in the reply_to
|
||||||
|
assert not obj.reply_to
|
||||||
|
|
||||||
results = plugins.NotifyEmail.parse_url(
|
results = plugins.NotifyEmail.parse_url(
|
||||||
'mailtos://user:pass123@hotmail.com')
|
'mailtos://user:pass123@hotmail.com')
|
||||||
obj = Apprise.instantiate(results, suppress_exceptions=False)
|
obj = Apprise.instantiate(results, suppress_exceptions=False)
|
||||||
assert isinstance(obj, plugins.NotifyEmail) is True
|
assert isinstance(obj, plugins.NotifyEmail) is True
|
||||||
|
# No entries in the reply_to
|
||||||
|
assert not obj.reply_to
|
||||||
|
|
||||||
#
|
#
|
||||||
# Test Port Over-Riding
|
# Test Port Over-Riding
|
||||||
|
@ -902,6 +912,8 @@ def test_plugin_email_url_parsing(mock_smtp, mock_smtp_ssl):
|
||||||
assert obj.port == 465
|
assert obj.port == 465
|
||||||
assert obj.from_addr == 'abc@xyz.cn'
|
assert obj.from_addr == 'abc@xyz.cn'
|
||||||
assert obj.secure_mode == 'ssl'
|
assert obj.secure_mode == 'ssl'
|
||||||
|
# No entries in the reply_to
|
||||||
|
assert not obj.reply_to
|
||||||
|
|
||||||
results = plugins.NotifyEmail.parse_url(
|
results = plugins.NotifyEmail.parse_url(
|
||||||
"mailtos://abc:password@xyz.cn?"
|
"mailtos://abc:password@xyz.cn?"
|
||||||
|
@ -914,3 +926,21 @@ def test_plugin_email_url_parsing(mock_smtp, mock_smtp_ssl):
|
||||||
assert obj.port == 465
|
assert obj.port == 465
|
||||||
assert obj.from_addr == 'abc@xyz.cn'
|
assert obj.from_addr == 'abc@xyz.cn'
|
||||||
assert obj.secure_mode == 'ssl'
|
assert obj.secure_mode == 'ssl'
|
||||||
|
# No entries in the reply_to
|
||||||
|
assert not obj.reply_to
|
||||||
|
|
||||||
|
#
|
||||||
|
# Test Reply-To Email
|
||||||
|
#
|
||||||
|
results = plugins.NotifyEmail.parse_url(
|
||||||
|
"mailtos://user:pass@example.com?reply=noreply@example.com")
|
||||||
|
obj = Apprise.instantiate(results, suppress_exceptions=False)
|
||||||
|
assert isinstance(obj, plugins.NotifyEmail) is True
|
||||||
|
# Verify our over-rides are in place
|
||||||
|
assert obj.smtp_host == 'example.com'
|
||||||
|
assert obj.from_addr == 'user@example.com'
|
||||||
|
assert obj.secure_mode == 'starttls'
|
||||||
|
assert obj.url().startswith(
|
||||||
|
'mailtos://user:pass@example.com')
|
||||||
|
# Test that our template over-ride worked
|
||||||
|
assert 'reply=noreply%40example.com' in obj.url()
|
||||||
|
|
Loading…
Reference in New Issue