diff --git a/apprise/plugins/NotifyEmail.py b/apprise/plugins/NotifyEmail.py index 80f88bf6..1b1b2fc1 100644 --- a/apprise/plugins/NotifyEmail.py +++ b/apprise/plugins/NotifyEmail.py @@ -45,7 +45,7 @@ from .NotifyBase import NotifyBase from ..URLBase import PrivacyMode from ..common import NotifyFormat, NotifyType from ..conversion import convert_between -from ..utils import is_email, parse_emails, is_hostname +from ..utils import is_ipaddr, is_email, parse_emails, is_hostname from ..AppriseLocale import gettext_lazy as _ from ..logger import logger @@ -1053,8 +1053,12 @@ class NotifyEmail(NotifyBase): # Prepare our target lists results['targets'] = [] - if not is_hostname(results['host'], ipv4=False, ipv6=False, - underscore=False): + if is_ipaddr(results['host']): + # Silently move on and do not disrupt any configuration + pass + + elif not is_hostname(results['host'], ipv4=False, ipv6=False, + underscore=False): if is_email(NotifyEmail.unquote(results['host'])): # Don't lose defined email addresses diff --git a/test/test_plugin_email.py b/test/test_plugin_email.py index f34bad59..a2882862 100644 --- a/test/test_plugin_email.py +++ b/test/test_plugin_email.py @@ -2006,3 +2006,45 @@ def test_plugin_host_detection_from_source_email(mock_smtp, mock_smtp_ssl): assert len(_to) == 1 assert _to[0] == 'john@yahoo.ca' assert _msg.split('\n')[-3] == 'body' + + +@mock.patch('smtplib.SMTP_SSL') +@mock.patch('smtplib.SMTP') +def test_plugin_email_by_ipaddr_1113(mock_smtp, mock_smtp_ssl): + """ + NotifyEmail() GitHub Issue 1113 + https://github.com/caronc/apprise/issues/1113 + Email with ip addresses not working + + """ + + response = mock.Mock() + mock_smtp_ssl.return_value = response + mock_smtp.return_value = response + + results = NotifyEmail.parse_url( + 'mailto://10.0.0.195:25/?to=alerts@example.com&' + 'from=sender@example.com') + + assert isinstance(results, dict) + assert results['user'] is None + assert results['password'] is None + assert results['host'] == '10.0.0.195' + assert results['from_addr'] == 'sender@example.com' + assert isinstance(results['targets'], list) + assert len(results['targets']) == 1 + assert results['targets'][0] == 'alerts@example.com' + assert results['port'] == 25 + + email = Apprise.instantiate(results, suppress_exceptions=False) + assert isinstance(email, NotifyEmail) is True + + assert len(email.targets) == 1 + assert (False, 'alerts@example.com') in email.targets + + assert email.from_addr == (False, 'sender@example.com') + assert email.user is None + assert email.password is None + assert email.smtp_host == '10.0.0.195' + assert email.port == 25 + assert email.targets == [(False, 'alerts@example.com')]