from mailu.internal import internal
from flask import current_app as app
import flask
@internal.route("/autoconfig/mozilla")
def autoconfig_mozilla():
# https://wiki.mozilla.org/Thunderbird:Autoconfiguration:ConfigFileFormat
hostname = app.config['HOSTNAME']
xml = f'''
%EMAILDOMAIN%
Email
Email
{hostname}
993
SSL
%EMAILADDRESS%
password-cleartext
{hostname}
465
SSL
%EMAILADDRESS%
password-cleartext
true
true
Configure your email client
\r\n'''
return flask.Response(xml, mimetype='text/xml', status=200)
@internal.route("/autoconfig/microsoft.json")
def autoconfig_microsoft_json():
proto = flask.request.args.get('Protocol', 'Autodiscoverv1')
if proto == 'Autodiscoverv1':
hostname = app.config['HOSTNAME']
json = f'{"Protocol":"Autodiscoverv1","Url":"https://{hostname}/autodiscover/autodiscover.xml"}'
return flask.Response(json, mimetype='application/json', status=200)
else:
return flask.abort(404)
@internal.route("/autoconfig/microsoft", methods=['GET', 'POST'])
def autoconfig_microsoft():
# https://docs.microsoft.com/en-us/previous-versions/office/office-2010/cc511507(v=office.14)?redirectedfrom=MSDN#Anchor_3
hostname = app.config['HOSTNAME']
xml = f'''
email
settings
IMAP
{hostname}
993
on
off
TLS
SMTP
{hostname}
465
on
off
TLS
'''
return flask.Response(xml, mimetype='text/xml', status=200)
@internal.route("/autoconfig/apple")
def autoconfig_apple():
# https://developer.apple.com/business/documentation/Configuration-Profile-Reference.pdf
hostname = app.config['HOSTNAME']
sitename = app.config['SITENAME']
xml = f'''
PayloadContent
EmailAccountDescription
{sitename}
EmailAccountName
{hostname}
EmailAccountType
EmailTypeIMAP
EmailAddress
IncomingMailServerAuthentication
EmailAuthPassword
IncomingMailServerHostName
{hostname}
IncomingMailServerPortNumber
993
IncomingMailServerUseSSL
IncomingMailServerUsername
IncomingPassword
OutgoingMailServerAuthentication
EmailAuthPassword
OutgoingMailServerHostName
{hostname}
OutgoingMailServerPortNumber
465
OutgoingMailServerUseSSL
OutgoingMailServerUsername
OutgoingPasswordSameAsIncomingPassword
PayloadDescription
{sitename}
PayloadDisplayName
{hostname}
PayloadIdentifier
{hostname}.email
PayloadOrganization
PayloadType
com.apple.mail.managed
PayloadUUID
72e152e2-d285-4588-9741-25bdd50c4d11
PayloadVersion
1
PreventAppSheet
PreventMove
SMIMEEnabled
disableMailRecentsSyncing
PayloadDescription
{hostname} - E-Mail Account Configuration
PayloadDisplayName
E-Mail Account {hostname}
PayloadIdentifier
E-Mail Account {hostname}
PayloadOrganization
{hostname}
PayloadRemovalDisallowed
PayloadType
Configuration
PayloadUUID
56db43a5-d29e-4609-a908-dce94d0be48e
PayloadVersion
1
\r\n'''
return flask.Response(xml, mimetype='text/xml', status=200)