0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

おわび

本記事は エンジニアが知っておくべき メール送信・運用ノウハウ、メールの認証技術やセキュリティについて投稿しよう! by blastengine Advent Calendar 2025 の一部のため、タグが設定してありますがblastengineは使っていません。

はじめに

Microsoft 365を導入すると、autodiscoverというCNAMEを設定するように求められます。調べてみるとExchange (Online)+Outlookでメールサーバの設定を自動化するためのもののようです。

さらに調べていくとインターネットの海で MS-OXDSCLI を見つけることができました。これを利用することでPostfixなどのメールサーバでもOutlookの設定自動化ができるのではないかと考えました。

設定例

というわけでXMLファイルを作成してみます。autodiscover.xml に設定を記述してHTTPSでアクセスできる場所に公開すれば良いようです。めんどうくさいので簡略化のためにメールサーバへの接続に必要な情報だけ返すことを考えて、静的にXMLを返すことにします。

メールドメインは example.com、メールサーバは mailsrv.example.com の場合、サーバ設定にもよりますが以下のようなXMLを作成します。

autodiscover.xml
<?xml version="1.0" encoding="utf-8" ?>
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006">
<Response xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a">
<Account>
    <AccountType>email</AccountType>
    <Action>settings</Action>
    <Protocol>
        <Type>SMTP</Type>
        <Server>mailsrv.example.com</Server>
        <Port>465</Port>
        <DomainRequired>on</DomainRequired>
        <SPA>off</SPA>
        <SSL>on</SSL>
    </Protocol>
    <Protocol>
        <Type>IMAP</Type>
        <Server>mailsrv.example.com</Server>
        <Port>993</Port>
        <DomainRequired>true</DomainRequired>
        <SPA>off</SPA>
        <SSL>on</SSL>
    </Protocol>
</Account>
</Response>
</Autodiscover>

できあがったXMLを https://<maildomain>/autodiscover/autodiscover.xml でアクセスできるようにします。今回の設定だと https://example.com/autodiscover/autodiscover.xml になるのですが、せっかくなのでM365みたいに autodiscover.example.com でこのXMLを取得できるように設定をしておきます。

すると、Outlookにメールアドレスとパスワードを入れるだけでメールサーバの設定が自動で完了し、コントロールパネルの Mail(Microsoft Outlook) からアカウントを設定する必要がなくなりました。SSL/TLSの設定やポート番号の入力間違いなども無くなり便利になりました!

あとがき

数年前に動作確認した後、そのうち記事に書こうと思っていたのですが、最近のOutlook(新しいOutlook)では普通に設定を入力できるようになっているようです。古いOutlookの運用で骨を折った自身への供養として残しておきます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?