package checker import "html/template" var templateFuncs = template.FuncMap{ "string": func(s reportStatus) string { return string(s) }, "badgeClass": func(s reportStatus) string { switch s { case statusOK: return "badge-ok" case statusWarn: return "badge-warn" case statusFail: return "badge-fail" case statusInfo: return "badge-info" } return "badge-skip" }, "chkClass": func(s reportStatus) string { switch s { case statusOK: return "chk-ok" case statusWarn: return "chk-warn" case statusFail: return "chk-fail" case statusInfo: return "chk-info" } return "chk-skip" }, "chkIcon": func(s reportStatus) string { switch s { case statusOK: return "✓" case statusWarn: return "!" case statusFail: return "✗" case statusInfo: return "i" } return "·" }, } var autoconfigHTMLTemplate = template.Must(template.New("autoconfig").Funcs(templateFuncs).Parse(` Email Autoconfiguration Report: {{.Domain}}

Email Autoconfiguration: {{.Domain}}

{{.HeadlineBadge}}

{{.HeadlineText}}

{{if .MX}}

MX: {{range $i, $m := .MX}}{{if $i}}, {{end}}{{$m}}{{end}}

{{end}}

Summary

{{range .Summary}}
{{chkIcon .Status}}{{.Label}}
{{.Message}}
{{end}}
{{if .Remediations}}

Fix this first

{{range .Remediations}}
{{.Title}}
{{.Body}}
{{end}}
{{end}}

Thunderbird-style probes ({{len .Autoconfig}})

{{range .Autoconfig}} {{.Source}} {{.URL}} {{.VerdictText}}
{{if .StatusCode}}
HTTP
{{.StatusCode}}
{{end}} {{if .ContentType}}
Content-Type
{{.ContentType}}
{{end}} {{if .DurationMs}}
Duration
{{.DurationMs}} ms
{{end}} {{if .BodyBytes}}
Body size
{{.BodyBytes}} bytes
{{end}} {{if .Redirected}}
Final URL
{{.FinalURL}}
{{end}} {{if .TLSSubject}}
TLS subject
{{.TLSSubject}}
{{end}} {{if .TLSIssuer}}
TLS issuer
{{.TLSIssuer}}
{{end}} {{if .TLSNotAfter}}
Expires
{{.TLSNotAfter}}
{{end}} {{if .TLSError}}
TLS error
{{.TLSError}}
{{end}} {{if .Error}}
Error
{{.Error}}
{{end}} {{if .ParseError}}
Parse error
{{.ParseError}}
{{end}}
{{end}}
{{if .ConfigServers.Incoming}}

Servers advertised by clientConfig

Incoming

{{range .ConfigServers.Incoming}} {{end}}
TypeHostnamePortSocketAuth
{{.Type}} {{.Hostname}} {{.Port}} {{if .Encrypted}}{{.SocketType}}{{else}}{{.SocketType}}{{end}} {{if .AuthSafe}}{{.Authentication}}{{else}}{{.Authentication}}{{end}}
{{if .ConfigServers.Outgoing}}

Outgoing

{{range .ConfigServers.Outgoing}} {{end}}
TypeHostnamePortSocketAuth
{{.Type}} {{.Hostname}} {{.Port}} {{if .Encrypted}}{{.SocketType}}{{else}}{{.SocketType}}{{end}} {{if .AuthSafe}}{{.Authentication}}{{else}}{{.Authentication}}{{end}}
{{end}} {{if or .ConfigServers.CardDAV .ConfigServers.CalDAV}}

Personal data (xDAV)

{{end}}
{{end}}

RFC 6186 SRV records

{{if .SRVRecords}} {{range .SRVRecords}} {{end}}
ServiceTargetPortPrioWeight
{{.Service}} {{if .Skip}}disabled (.){{else}}{{.Target}}{{end}} {{.Port}} {{.Priority}} {{.Weight}}
{{else}}

No SRV records found.

{{end}}

Microsoft Autodiscover ({{len .Autodiscover}})

{{if .Autodiscover}} {{range .Autodiscover}} {{.Source}} {{.URL}} {{.VerdictText}}
{{if .StatusCode}}
HTTP
{{.StatusCode}}
{{end}} {{if .DurationMs}}
Duration
{{.DurationMs}} ms
{{end}} {{if .TLSSubject}}
TLS subject
{{.TLSSubject}}
{{end}} {{if .Error}}
Error
{{.Error}}
{{end}} {{if .ParseError}}
Parse error
{{.ParseError}}
{{end}}
{{end}} {{else}}

Autodiscover probes were disabled.

{{end}}

Example config-v1.1.xml

Paste-ready starting point. Adjust hostnames and ports before publishing.

{{.ExampleXML}}
`))