Add Thunderbird auto configuration mechanism
This commit is contained in:
parent
471c5edaa6
commit
4d841636bd
|
@ -38,6 +38,7 @@ import AddNameToUsers from "./migrations/AddNameToUsers";
|
|||
import CreateMailTables from "./migrations/CreateMailTables";
|
||||
import MailboxBackendController from "./controllers/MailboxBackendController";
|
||||
import RedirectBackComponent from "wms-core/components/RedirectBackComponent";
|
||||
import MailAutoConfigController from "./controllers/MailAutoConfigController";
|
||||
|
||||
export default class App extends Application {
|
||||
private readonly port: number;
|
||||
|
@ -138,8 +139,9 @@ export default class App extends Application {
|
|||
this.use(new MailController());
|
||||
|
||||
// Other functionnality
|
||||
this.use(new MailAutoConfigController());
|
||||
|
||||
// Semi-static routes
|
||||
this.use(new HomeController());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
import Controller from "wms-core/Controller";
|
||||
import {Request, Response} from "express";
|
||||
import config from "config";
|
||||
import MailDomain from "../models/MailDomain";
|
||||
|
||||
export default class MailAutoConfigController extends Controller {
|
||||
public routes(): void {
|
||||
this.get('/.well-known/autoconfig/mail/config-v1.1.xml', this.getAutoConfig, 'mail-auto-config');
|
||||
}
|
||||
|
||||
/**
|
||||
* See view and https://wiki.mozilla.org/Thunderbird:Autoconfiguration:ConfigFileFormat
|
||||
*/
|
||||
protected async getAutoConfig(req: Request, res: Response): Promise<void> {
|
||||
res.contentType('text/xml');
|
||||
res.render('mail-auto-config.xml.njk', {
|
||||
domain: config.get<string>('domain'),
|
||||
domains: await MailDomain.select().get(),
|
||||
display_name: 'Rainbox Email',
|
||||
display_name_short: 'Rainbox',
|
||||
username: '%EMAILADDRESS%',
|
||||
auth_method: 'password-cleartext',
|
||||
imap: {
|
||||
server: 'rainbox.email',
|
||||
port: '143',
|
||||
method: 'STARTTLS',
|
||||
},
|
||||
pop3: {
|
||||
server: 'rainbox.email',
|
||||
port: '110',
|
||||
method: 'STARTTLS',
|
||||
},
|
||||
smtp: {
|
||||
server: 'rainbox.email',
|
||||
port: '587',
|
||||
method: 'STARTTLS',
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0"?>
|
||||
<clientConfig version="1.1">
|
||||
<emailProvider id="{{ domain }}">
|
||||
<domain>{{ domain }}</domain>
|
||||
|
||||
{% for d in domains %}
|
||||
<domain>{{ d.name }}</domain>
|
||||
{% endfor %}
|
||||
|
||||
<displayName>{{ display_name }}</displayName>
|
||||
<displayShortName>{{ display_name_short }}</displayShortName>
|
||||
|
||||
<outgoingServer type="imap">
|
||||
<hostname>{{ imap.server }}</hostname>
|
||||
<port>{{ imap.port }}</port>
|
||||
<socketType>{{ imap.method }}</socketType>
|
||||
<username>{{ username }}</username>
|
||||
<authentication>{{ auth_method }}</authentication>
|
||||
</outgoingServer>
|
||||
|
||||
<incomingServer type="pop3">
|
||||
<hostname>{{ pop3.server }}</hostname>
|
||||
<port>{{ pop3.port }}</port>
|
||||
<socketType>{{ pop3.method }}</socketType>
|
||||
<username>{{ username }}</username>
|
||||
<authentication>{{ auth_method }}</authentication>
|
||||
</incomingServer>
|
||||
|
||||
<outgoingServer type="smtp">
|
||||
<hostname>{{ smtp.server }}</hostname>
|
||||
<port>{{ smtp.port }}</port>
|
||||
<socketType>{{ smtp.method }}</socketType>
|
||||
<username>{{ username }}</username>
|
||||
<authentication>{{ auth_method }}</authentication>
|
||||
</outgoingServer>
|
||||
</emailProvider>
|
||||
</clientConfig>
|
Loading…
Reference in New Issue