Discourse에서 Azure Communication Service로 SMTP 설정이 안 돼요

Hey everyone,

I’ve been wrestling with setting up SMTP on my Discourse installation, and it’s been quite the challenge. I’ve delved into numerous posts like this one without luck.

Here’s the scoop: I suspect my issues are tied to the format and length of the username and password that I’m required to use. I’m tapping into Azure Communication Service for my SMTP server, which demands a specific configuration involving an Azure Entra App (formerly Azure Active Directory).

To cut to the chase, the username format looks something like this (not actual credentials, just an example):

<Azure Communication Services Resource name>.<Entra Application Id>.<Entra Application Tenant Id>

Here’s an example: my-communication-service.7d8233e0-c230-4468-a2de-1d03aa64bb71.49ba4f9c-3b18-43df-b5fd-5e203ba6e031

For more details, check out this link.

Meanwhile, the password needs to adhere to an Azure-generated secret format, such as:

b_C8Q~WjHH~MtFQptMj8wR1KroOZYigGy3A3Zc5M

Now, I’ve got this setup working smoothly in C# with similar credentials.

 private static void SendMail()
    {
        string smtpAuthUsername = "my-communication-service.7d8233e0-c230-4468-a2de-1d03aa64bb71.49ba4f9c-3b18-43df-b5fd-5e203ba6e031";
        string smtpAuthPassword = "a~C8Q~WjHH~MtFQptMj8wR1KroOZYigGy3A3Zc5M";

        string sender = "DoNotReply@my-domain.com";
        string recipient = "admin@my-domain";
        string subject = "You a chosen";
        string body = "One gorgeous body";
        string smtpHostUrl = "smtp.azurecomm.net";

        using (var client = new SmtpClient(smtpHostUrl))
        {
            client.Port = 587;
            client.Credentials = new NetworkCredential(smtpAuthUsername, smtpAuthPassword);
            client.EnableSsl = false;

            var message = new MailMessage(sender, recipient, subject, body);

            try
            {
                client.Send(message);
                Console.WriteLine("The email was successfully sent using Smtp.");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Smtp failed with the exception: {ex.Message}.");
            }
        }
    }

However, when I try to implement these settings in Discourse, things start acting up. Here’s what I’ve got configured:

DISCOURSE_SMTP_ADDRESS: smtp.azurecomm.net
DISCOURSE_SMTP_PORT: 587
DISCOURSE_SMTP_USER_NAME: "my-communication-service.7d8233e0-c230-4468-a2de-1d03aa64bb71.49ba4f9c-3b18-43df-b5fd-5e203ba6e031"
DISCOURSE_SMTP_PASSWORD: "b_C8Q~WjHH~MtFQptMj8wR1KroOZYigGy3A3Zc5M"
DISCOURSE_SMTP_ENABLE_START_TLS: true
DISCOURSE_SMTP_DOMAIN: my-domain.com
DISCOURSE_NOTIFICATION_EMAIL: DoNotReply@my-domain.com

However, despite this setup, I keep getting an authentication error as per the log snippet:

Job exception: Net::SMTPAuthenticationError

I’ve experimented with enclosing the username and password in various ways—single quotes, double quotes, or even leaving them out entirely. But the outcome remains the same.

Any pointers or suggestions on what else I could try would be greatly appreciated.

Hello, I have met the same issue with Azure Communication Service.

According to the Microsoft Docs, I think it might be that Microsoft Entra must be supported by the application but Discourse unfortunately doesn’t support that.

Meanwhile, I’m looking forward to any other available methods, too.

저도 동일한 문제를 겪었고 웹 검색을 통해 이 주제를 찾았습니다. (이전 Microsoft 365 메일 서버가 비밀번호 기반 인증을 중단하기 전과 마찬가지로) 현재 시점에서는 AUTH PLAIN이 아닌 AUTH LOGIN만 지원되는 것으로 보입니다. Discourse에서는 기본적으로 AUTH PLAIN이 사용되도록 설정되어 있습니다.

컨테이너 설정에서 DISCOURSE_SMTP_AUTHENTICATION: login으로 설정하면 이메일이 정상적으로 작동합니다. 참고할 점으로, 기본적으로 허용되는 ‘from’ 이메일 주소는 기본값인 DoNotReply@domain.example뿐입니다. 이 값을 설정하지 않으면 “550 5.3.5 Email sender’s username is invalid” 오류로 인해 이메일이 거부됩니다.

@justinm 덕분에 이제 수정된 것 같습니다.

저도 여기의 제안을 따라 설정을 시도해 보았습니다. 하지만 작동하지 않았고, SMTP 문제와 관련된 로그도 찾을 수 없었습니다. 어떤 로그 파일을 확인해야 하는지 아시나요? 감사합니다.

/logs URL을 확인해 보세요.

디버깅 중이라면 rake 'emails:test[your_email]' 작업을 시도하는 것이 더 빠를 수 있습니다.

컨테이너를 다시 빌드하지 않고도 환경 변수를 설정하여 다른 설정을 시도할 수 있습니다. 예를 들어:

$ DISCOURSE_SMTP_PORT=587 DISCOURSE_SMTP_USER_NAME=bilbo DISCOURSE_SMTP_PASSWORD=ring rake emails:test'[frodo@shire.net]'

discourse/discourse 2025.12.0 이미지를 사용 중입니다. 흥미롭게도 DISCOURSE_SMTP_PASSWORD를 설정하지 않았음에도 production.log에는 아무런 오류가 표시되지 않습니다. 마치 관리자 사용자 등록 작업이 호출되지 않는 것처럼 보입니다. 현재 확인할 수 있는 로그는 다음과 같습니다.

Started POST “/finish-installation/register” for xxx at 2026-01-09 16:48:11 +0000
Processing by FinishInstallationController#register as HTML
Parameters: {“authenticity_token”=>“xxx”, “email”=>“xxx”, “username”=>“xxx”, “password”=>“[FILTERED]”, “commit”=>“Register”}
Redirected to xxx

Completed 302 Found in 489ms (ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 131.6ms)

https://whateveryoursiteis.com/logs를 찾고 계십니다.

수정: 문제 해결됨. 원인은 사용자 이름 환경 변수가 DISCOURSE_SMTP_USERNAME이 아니라 DISCOURSE_SMTP_USER_NAME이어야 한다는 것이었습니다.

아래 설정이 작동합니다:

DISCOURSE_SMTP_USER_NAME: <Azure communication service SMTP user name (does not need to be <Azure Communication Services Resource name>.<Entra Application Id>.<Entra Application Tenant Id>>
DISCOURSE_SMTP_PASSWORD: xxx
DISCOURSE_SMTP_DOMAIN: yourdomain
DISCOURSE_NOTIFICATION_EMAIL:  DoNotReply@yourdomain
DISCOURSE_SMTP_AUTHENTICATION: login
DISCOURSE_SMTP_ENABLE_START_TLS: true

컨테이너에서 rake admin:create를 실행하면 계정을 직접 생성할 수 있습니다.

또한, 환경 변수 처리 방식이 변경되었음을 방금 알게 되었습니다. 이제 컨테이너 시작 시를 제외하고는 환경 변수를 더 이상 참조하지 않습니다.

다른 값을 테스트하려면 /var/www/discourse/config/discourse.conf 파일을 수정해야 합니다.

:+1: