Skip to content

Commit

Permalink
fix: autodiscover config
Browse files Browse the repository at this point in the history
refactored imap/pop/smtp under single account
added ssl property based on socket

---------

Signed-off-by: madmath03 <mb.mathieu.brunot@gmail.com>
Co-authored-by: y <y@y.de>
Co-authored-by: madmath03 <mb.mathieu.brunot@gmail.com>
  • Loading branch information
3 people authored Feb 3, 2024
1 parent 620af02 commit 66c144e
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 96 deletions.
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,21 @@ function *autodiscover() {
const popenc = settings.pop.socket === "STARTTLS" ? "TLS" : settings.pop.socket;
const smtpenc = settings.smtp.socket === "STARTTLS" ? "TLS" : settings.smtp.socket;

const imapssl = settings.imap.socket === "SSL" ? "on" : "off";
const popssl = settings.pop.socket === "SSL" ? "on" : "off";
const smtpssl = settings.smtp.socket === "SSL" ? "on" : "off";

yield this.render("autodiscover", {
schema: xmlns,
email,
username,
domain,
imapenc,
popenc,
smtpenc
smtpenc,
imapssl,
popssl,
smtpssl
});
}

Expand Down
164 changes: 69 additions & 95 deletions views/autodiscover.xml
Original file line number Diff line number Diff line change
@@ -1,97 +1,71 @@
<?xml version="1.0" encoding="utf-8" ?>
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006">
<Response xmlns="{{schema}}">
<User>
<DisplayName>{{info.name}} Email</DisplayName>
</User>

{%- if imap.host %}
<Account>
<AccountType>email</AccountType>
<Action>settings</Action>
<ServiceHome>{{info.url}}</ServiceHome>

<Protocol>
<Type>IMAP</Type>
<TTL>1</TTL>

<Server>{{imap.host}}</Server>
<Port>{{imap.port}}</Port>

<LoginName>{{email}}</LoginName>

<DomainRequired>on</DomainRequired>
<DomainName>{{domain}}</DomainName>

<SPA>off</SPA>
<Encryption>{{imapenc}}</Encryption>
<AuthRequired>on</AuthRequired>
</Protocol>
</Account>
{% endif -%}

{%- if pop.host %}
<Account>
<AccountType>email</AccountType>
<Action>settings</Action>
<ServiceHome>{{info.url}}</ServiceHome>

<Protocol>
<Type>POP</Type>
<TTL>1</TTL>

<Server>{{pop.host}}</Server>
<Port>{{pop.port}}</Port>

<LoginName>{{email}}</LoginName>

<DomainRequired>on</DomainRequired>
<DomainName>{{domain}}</DomainName>

<SPA>off</SPA>
<Encryption>{{popenc}}</Encryption>
<AuthRequired>on</AuthRequired>
</Protocol>
</Account>
{% endif -%}

{%- if smtp.host %}
<Account>
<AccountType>email</AccountType>
<Action>settings</Action>
<ServiceHome>{{info.url}}</ServiceHome>

<Protocol>
<Type>SMTP</Type>
<TTL>1</TTL>

<Server>{{smtp.host}}</Server>
<Port>{{smtp.port}}</Port>

<LoginName>{{email}}</LoginName>

<DomainRequired>on</DomainRequired>
<DomainName>{{domain}}</DomainName>

<SPA>off</SPA>
<Encryption>{{smtpenc}}</Encryption>
<AuthRequired>on</AuthRequired>
</Protocol>
</Account>
{% endif -%}

{%- if mobilesync.url %}
<Action>
<Settings>
<Server>
<Type>MobileSync</Type>
<Url>{{mobilesync.url}}</Url>
{%- if mobilesync.name %}
<Name>{{mobilesync.name}}</Name>
{% endif -%}
</Server>
</Settings>
</Action>
{% endif -%}
</Response>
<Autodiscover
xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006">
<Response
xmlns="{{schema}}">
<User>
<DisplayName>{{info.name}}</DisplayName>
</User>
<Account>
<AccountType>email</AccountType>
<Action>settings</Action>
<ServiceHome>{{info.url}}</ServiceHome>
{%- if imap.host %}
<Protocol>
<Type>IMAP</Type>
<Server>{{imap.host}}</Server>
<Port>{{imap.port}}</Port>
<LoginName>{{email}}</LoginName>
<DomainRequired>on</DomainRequired>
<DomainName>{{domain}}</DomainName>
<SPA>on</SPA>
<SSL>{{imapssl}}</SSL>
<Encryption>{{imapenc}}</Encryption>
<AuthRequired>on</AuthRequired>
</Protocol>
{% endif -%}

{%- if pop.host %}
<Protocol>
<Type>POP</Type>
<Server>{{pop.host}}</Server>
<Port>{{pop.port}}</Port>
<LoginName>{{email}}</LoginName>
<DomainRequired>on</DomainRequired>
<DomainName>{{domain}}</DomainName>
<SPA>on</SPA>
<SSL>{{popssl}}</SSL>
<Encryption>{{popenc}}</Encryption>
<AuthRequired>on</AuthRequired>
</Protocol>
{% endif -%}
{%- if smtp.host %}
<Protocol>
<Type>SMTP</Type>
<Server>{{smtp.host}}</Server>
<Port>{{smtp.port}}</Port>
<LoginName>{{email}}</LoginName>
<DomainRequired>on</DomainRequired>
<DomainName>{{domain}}</DomainName>
<SPA>on</SPA>
<SSL>{{smtpssl}}</SSL>
<Encryption>{{smtpenc}}</Encryption>
<AuthRequired>on</AuthRequired>
</Protocol>
{% endif -%}
</Account>
{%- if mobilesync.url %}
<Action>
<Settings>
<Server>
<Type>MobileSync</Type>
<Url>{{mobilesync.url}}</Url>
{%- if mobilesync.name %}
<Name>{{mobilesync.name}}</Name>
{% endif -%}
</Server>
</Settings>
</Action>
{% endif -%}
</Response>
</Autodiscover>

0 comments on commit 66c144e

Please sign in to comment.