mirror of
https://github.com/caronc/apprise.git
synced 2024-11-29 11:34:10 +01:00
commit
0621e2ff4a
2
README
2
README
@ -144,7 +144,7 @@ Email Support
|
||||
mailtos://domain.com:465?user=userid&pass=passwordmailtos://user@hotmail.com&pass=password
|
||||
mailtos://userid:password@example.com?smtp=mail.example.com&from=noreply@example.com&name=no%20reply
|
||||
|
||||
Apprise have some email services built right into it (such as hotmail, gmail, etc) that greatly simplify the mailto:// service.
|
||||
Apprise have some email services built right into it (such as yahoo, fastmail, hotmail, gmail, etc) that greatly simplify the mailto:// service.
|
||||
|
||||
Custom Notifications
|
||||
--------------------
|
||||
|
@ -59,7 +59,7 @@ The table below identifies the services this tool supports and some example serv
|
||||
| [mailto://](https://github.com/caronc/apprise/wiki/Notify_email) | (TCP) 25 | mailto://userid:pass@domain.com<br />mailto://domain.com?user=userid&pass=password<br/>mailto://domain.com:2525?user=userid&pass=password<br />mailto://user@gmail.com&pass=password<br />mailto://userid:password@example.com?smtp=mail.example.com&from=noreply@example.com&name=no%20reply
|
||||
| [mailtos//](https://github.com/caronc/apprise/wiki/Notify_email) | (TCP) 587 | mailtos://userid:pass@domain.com<br />mailtos://domain.com?user=userid&pass=password<br/>mailtos://domain.com:465?user=userid&pass=password<br />mailtos://user@hotmail.com&pass=password<br />mailtos://userid:password@example.com?smtp=mail.example.com&from=noreply@example.com&name=no%20reply
|
||||
|
||||
Apprise have some email services built right into it (such as hotmail, gmail, etc) that greatly simplify the mailto:// service. See more details [here](https://github.com/caronc/apprise/wiki/Notify_email).
|
||||
Apprise have some email services built right into it (such as yahoo, fastmail, hotmail, gmail, etc) that greatly simplify the mailto:// service. See more details [here](https://github.com/caronc/apprise/wiki/Notify_email).
|
||||
|
||||
### Custom Notifications
|
||||
| Post Method | Service ID | Default Port | Example Syntax |
|
||||
|
@ -59,7 +59,7 @@ class NotifyDiscord(NotifyBase):
|
||||
secure_protocol = 'discord'
|
||||
|
||||
# A URL that takes you to the setup/help of the specific protocol
|
||||
setup_url = 'https://github.com/caronc/apprise/wiki/Notify_discored'
|
||||
setup_url = 'https://github.com/caronc/apprise/wiki/Notify_discord'
|
||||
|
||||
# Discord Webhook
|
||||
notify_url = 'https://discordapp.com/api/webhooks'
|
||||
|
@ -40,6 +40,18 @@ class WebBaseLogin(object):
|
||||
USERID = 'UserID'
|
||||
|
||||
|
||||
# Secure Email Modes
|
||||
class SecureMailMode(object):
|
||||
SSL = "ssl"
|
||||
STARTTLS = "starttls"
|
||||
|
||||
|
||||
# Define all of the secure modes (used during validation)
|
||||
SECURE_MODES = (
|
||||
SecureMailMode.SSL,
|
||||
SecureMailMode.STARTTLS,
|
||||
)
|
||||
|
||||
# To attempt to make this script stupid proof, if we detect an email address
|
||||
# that is part of the this table, we can pre-use a lot more defaults if they
|
||||
# aren't otherwise specified on the users input.
|
||||
@ -54,6 +66,7 @@ WEBBASE_LOOKUP_TABLE = (
|
||||
'port': 587,
|
||||
'smtp_host': 'smtp.gmail.com',
|
||||
'secure': True,
|
||||
'secure_mode': SecureMailMode.STARTTLS,
|
||||
'login_type': (WebBaseLogin.EMAIL, )
|
||||
},
|
||||
),
|
||||
@ -68,6 +81,7 @@ WEBBASE_LOOKUP_TABLE = (
|
||||
'port': 465,
|
||||
'smtp_host': 'secure.emailsrvr.com',
|
||||
'secure': True,
|
||||
'secure_mode': SecureMailMode.STARTTLS,
|
||||
'login_type': (WebBaseLogin.EMAIL, )
|
||||
},
|
||||
),
|
||||
@ -82,6 +96,7 @@ WEBBASE_LOOKUP_TABLE = (
|
||||
'port': 587,
|
||||
'smtp_host': 'smtp.live.com',
|
||||
'secure': True,
|
||||
'secure_mode': SecureMailMode.STARTTLS,
|
||||
'login_type': (WebBaseLogin.EMAIL, )
|
||||
},
|
||||
),
|
||||
@ -96,6 +111,60 @@ WEBBASE_LOOKUP_TABLE = (
|
||||
'port': 465,
|
||||
'smtp_host': 'smtp.mail.yahoo.com',
|
||||
'secure': True,
|
||||
'secure_mode': SecureMailMode.STARTTLS,
|
||||
'login_type': (WebBaseLogin.EMAIL, )
|
||||
},
|
||||
),
|
||||
|
||||
# Fast Mail (Series 1)
|
||||
(
|
||||
'Fast Mail',
|
||||
re.compile(
|
||||
r'^((?P<label>[^+]+)\+)?(?P<id>[^@]+)@'
|
||||
r'(?P<domain>fastmail\.(com|cn|co\.uk|com\.au|de|es|fm|fr|im|'
|
||||
r'in|jp|mx|net|nl|org|se|to|tw|uk|us))$', re.I),
|
||||
{
|
||||
'port': 465,
|
||||
'smtp_host': 'smtp.fastmail.com',
|
||||
'secure': True,
|
||||
'secure_mode': SecureMailMode.SSL,
|
||||
'login_type': (WebBaseLogin.EMAIL, )
|
||||
},
|
||||
),
|
||||
# Fast Mail (Series 2)
|
||||
(
|
||||
'Fast Mail Extended Addresses',
|
||||
re.compile(
|
||||
r'^((?P<label>[^+]+)\+)?(?P<id>[^@]+)@'
|
||||
r'(?P<domain>123mail\.org|airpost\.net|eml\.cc|fmail\.co\.uk|'
|
||||
r'fmgirl\.com|fmguy\.com|mailbolt\.com|mailcan\.com|'
|
||||
r'mailhaven\.com|mailmight\.com|ml1\.net|mm\.st|myfastmail\.com|'
|
||||
r'proinbox\.com|promessage\.com|rushpost\.com|sent\.(as|at|com)|'
|
||||
r'speedymail\.org|warpmail\.net|xsmail\.com|150mail\.com|'
|
||||
r'150ml\.com|16mail\.com|2-mail\.com|4email\.net|50mail\.com|'
|
||||
r'allmail\.net|bestmail\.us|cluemail\.com|elitemail\.org|'
|
||||
r'emailcorner\.net|emailengine\.(net|org)|emailgroups\.net|'
|
||||
r'emailplus\.org|emailuser\.net|f-m\.fm|fast-email\.com|'
|
||||
r'fast-mail\.org|fastem\.com|fastemail\.us|fastemailer\.com|'
|
||||
r'fastest\.cc|fastimap\.com|fastmailbox\.net|fastmessaging\.com|'
|
||||
r'fea\.st|fmailbox\.com|ftml\.net|h-mail\.us|hailmail\.net|'
|
||||
r'imap-mail\.com|imap\.cc|imapmail\.org|inoutbox\.com|'
|
||||
r'internet-e-mail\.com|internet-mail\.org|internetemails\.net|'
|
||||
r'internetmailing\.net|jetemail\.net|justemail\.net|'
|
||||
r'letterboxes\.org|mail-central\.com|mail-page\.com|'
|
||||
r'mailandftp\.com|mailas\.com|mailc\.net|mailforce\.net|'
|
||||
r'mailftp\.com|mailingaddress\.org|mailite\.com|mailnew\.com|'
|
||||
r'mailsent\.net|mailservice\.ms|mailup\.net|mailworks\.org|'
|
||||
r'mymacmail\.com|nospammail\.net|ownmail\.net|petml\.com|'
|
||||
r'postinbox\.com|postpro\.net|realemail\.net|reallyfast\.biz|'
|
||||
r'reallyfast\.info|speedpost\.net|ssl-mail\.com|swift-mail\.com|'
|
||||
r'the-fastest\.net|the-quickest\.com|theinternetemail\.com|'
|
||||
r'veryfast\.biz|veryspeedy\.net|yepmail\.net)$', re.I),
|
||||
{
|
||||
'port': 465,
|
||||
'smtp_host': 'smtp.fastmail.com',
|
||||
'secure': True,
|
||||
'secure_mode': SecureMailMode.SSL,
|
||||
'login_type': (WebBaseLogin.EMAIL, )
|
||||
},
|
||||
),
|
||||
@ -141,6 +210,9 @@ class NotifyEmail(NotifyBase):
|
||||
# Default Secure Port
|
||||
default_secure_port = 587
|
||||
|
||||
# Default Secure Mode
|
||||
default_secure_mode = SecureMailMode.STARTTLS
|
||||
|
||||
# Default SMTP Timeout (in seconds)
|
||||
connect_timeout = 15
|
||||
|
||||
@ -181,6 +253,13 @@ class NotifyEmail(NotifyBase):
|
||||
# Now detect the SMTP Server
|
||||
self.smtp_host = kwargs.get('smtp_host', '')
|
||||
|
||||
# Now detect secure mode
|
||||
self.secure_mode = kwargs.get('secure_mode', self.default_secure_mode)
|
||||
|
||||
if self.secure_mode not in SECURE_MODES:
|
||||
raise TypeError(
|
||||
'Invalid secure mode specified: %s.' % self.secure_mode)
|
||||
|
||||
# Apply any defaults based on certain known configurations
|
||||
self.NotifyEmailDefaults()
|
||||
|
||||
@ -212,7 +291,8 @@ class NotifyEmail(NotifyBase):
|
||||
.get('port', self.port)
|
||||
self.secure = WEBBASE_LOOKUP_TABLE[i][2]\
|
||||
.get('secure', self.secure)
|
||||
|
||||
self.secure_mode = WEBBASE_LOOKUP_TABLE[i][2]\
|
||||
.get('secure_mode', self.secure_mode)
|
||||
self.smtp_host = WEBBASE_LOOKUP_TABLE[i][2]\
|
||||
.get('smtp_host', self.smtp_host)
|
||||
|
||||
@ -273,16 +353,21 @@ class NotifyEmail(NotifyBase):
|
||||
socket = None
|
||||
try:
|
||||
self.logger.debug('Connecting to remote SMTP server...')
|
||||
socket = smtplib.SMTP(
|
||||
socket_func = smtplib.SMTP
|
||||
if self.secure and self.secure_mode == SecureMailMode.SSL:
|
||||
self.logger.debug('Securing connection with SSL...')
|
||||
socket_func = smtplib.SMTP_SSL
|
||||
|
||||
socket = socket_func(
|
||||
self.smtp_host,
|
||||
self.port,
|
||||
None,
|
||||
timeout=self.timeout,
|
||||
)
|
||||
|
||||
if self.secure:
|
||||
if self.secure and self.secure_mode == SecureMailMode.STARTTLS:
|
||||
# Handle Secure Connections
|
||||
self.logger.debug('Securing connection with TLS...')
|
||||
self.logger.debug('Securing connection with STARTTLS...')
|
||||
socket.starttls()
|
||||
|
||||
if self.user and self.password:
|
||||
@ -329,6 +414,7 @@ class NotifyEmail(NotifyBase):
|
||||
|
||||
# Default Format is HTML
|
||||
results['notify_format'] = NotifyFormat.HTML
|
||||
results['secure_mode'] = NotifyEmail.default_secure_mode
|
||||
|
||||
to_addr = ''
|
||||
from_addr = ''
|
||||
@ -379,6 +465,10 @@ class NotifyEmail(NotifyBase):
|
||||
# Extract the smtp server
|
||||
smtp_host = NotifyBase.unquote(results['qsd']['smtp'])
|
||||
|
||||
if 'mode' in results['qsd'] and len(results['qsd']['mode']):
|
||||
# Extract the secure mode to over-ride the default
|
||||
results['secure_mode'] = results['qsd']['mode'].lower()
|
||||
|
||||
results['to'] = to_addr
|
||||
results['from'] = from_addr
|
||||
results['smtp_host'] = smtp_host
|
||||
|
@ -62,6 +62,9 @@ TEST_URLS = (
|
||||
('mailto://user:pass@yahoo.ca', {
|
||||
'instance': plugins.NotifyEmail,
|
||||
}),
|
||||
('mailto://user:pass@fastmail.com', {
|
||||
'instance': plugins.NotifyEmail,
|
||||
}),
|
||||
|
||||
# Custom Emails
|
||||
('mailtos://user:pass@nuxref.com:567', {
|
||||
@ -121,6 +124,18 @@ TEST_URLS = (
|
||||
('mailtos://nuxref.com?to=test', {
|
||||
'exception': TypeError,
|
||||
}),
|
||||
# Invalid Secure Mode
|
||||
('mailtos://user:pass@example.com?mode=notamode', {
|
||||
'exception': TypeError,
|
||||
}),
|
||||
# STARTTLS flag checking
|
||||
('mailtos://user:pass@gmail.com?mode=starttls', {
|
||||
'instance': plugins.NotifyEmail,
|
||||
}),
|
||||
# SSL flag checking
|
||||
('mailtos://user:pass@gmail.com?mode=ssl', {
|
||||
'instance': plugins.NotifyEmail,
|
||||
}),
|
||||
# Can make a To address using what we have (l2g@nuxref.com)
|
||||
('mailtos://nuxref.com?user=l2g&pass=.', {
|
||||
'instance': plugins.NotifyEmail,
|
||||
@ -135,7 +150,8 @@ TEST_URLS = (
|
||||
|
||||
|
||||
@mock.patch('smtplib.SMTP')
|
||||
def test_email_plugin(mock_smtp):
|
||||
@mock.patch('smtplib.SMTP_SSL')
|
||||
def test_email_plugin(mock_smtp, mock_smtpssl):
|
||||
"""
|
||||
API: NotifyEmail Plugin()
|
||||
|
||||
@ -166,6 +182,7 @@ def test_email_plugin(mock_smtp):
|
||||
|
||||
# Create a mock SMTP Object
|
||||
mock_smtp.return_value = mock_socket
|
||||
mock_smtpssl.return_value = mock_socket
|
||||
|
||||
if test_smtplib_exceptions:
|
||||
# Handle exception testing; first we turn the boolean flag ito
|
||||
@ -256,7 +273,8 @@ def test_email_plugin(mock_smtp):
|
||||
|
||||
|
||||
@mock.patch('smtplib.SMTP')
|
||||
def test_webbase_lookup(mock_smtp):
|
||||
@mock.patch('smtplib.SMTP_SSL')
|
||||
def test_webbase_lookup(mock_smtp, mock_smtpssl):
|
||||
"""
|
||||
API: Web Based Lookup Tests
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user