So if the openssl test works but the connection test run by discourse-doctor still fails when using those settings what is next? Even though the openssl test works my discourse connection still fails with 504 5.7.4 Unrecognized authentication type… Presumably it is not recognizing the LOGIN auth method. I tried adding DISCOURSE_SMTP_AUTHENTICATION: login to the app.yml file, but that has not helped.
FWIW, here is what I have found. I went into the docker image and started monkeying around with the lib/tasks/emails.rake script and the config/discourse.conf file. Several hours later, after trying every possible combination of smtp.office365.com and .mail.protection.outlook.com AUTH login and AUTH plain I uncommented the block above the STMP start.
# We would like to do this, but Net::SMTP errors out using starttls
#Net::SMTP.start(smtp[:address], smtp[:port]) do |s|
# s.starttls if !!smtp[:enable_starttls_auto] && s.capable_starttls?
# s.auth_login(smtp[:user_name], smtp[:password])
#end
Running that as-is resulted in a read timeout.
Modifying it like this - calling new rather than start resulted in a successful send.
Net::STMP.new(smtp[:address], smtp[:port]) do |s|
s.enable_starttls
s.auth_login(smtp[:user_name], smtp[:password])
end
This is my first exposure to Ruby, rake and friends. I can’t explain why it works or if is a ‘good thing’ for general cases.
J.
Eu utilizo o socketlabs.com como meu serviço de entrega de e-mail e tive um problema semelhante. No meu caso, a solução foi editar o arquivo lib/tasks/emails.rake da seguinte forma:
Alterar a linha: Net::SMTP.start(smtp[:address], smtp[:port], 'localhost', smtp[:user_name], smtp[:password])
para Net::SMTP.start(smtp[:address], smtp[:port], 'localhost', smtp[:user_name], smtp[:password], smtp[:authentication])
Sem essa alteração, o DISCOURSE_SMTP_AUTHENTICATION: login não é passado para o código SMTP de nível inferior.
Eu não testei se o código modificado ainda funciona para outros métodos de autenticação, mas isso resolve o problema para autenticação login.
Posso confirmar que adicionar smtp[:authentication]
à chamada Net::SMTP.start e definir DISCOURSE_SMTP_AUTHENTICATION: login
no app.yml resolve o problema na página de teste de e-mail.
Acredito que os e-mails regulares são enviados pela biblioteca mail, e definir DISCOURSE_SMTP_AUTHENTICATION: login
no app.yml é suficiente para que a biblioteca funcione corretamente.
Ainda assim, acredito que lib/tasks/emails.rake deveria ser corrigido para usar a configuração DISCOURSE_SMTP_AUTHENTICATION. Isso economizaria alguma depuração desnecessária.
Como uma atualização geral sobre este problema, a Microsoft está no processo de desativar a autenticação legada para SMTP e POP3, o que vai complicar as coisas se você estiver usando o O365 como provedor de e-mail. A política padrão aplicada agora é proibir a autenticação SMTP, e você precisa habilitá-la por caixa de correio. Espero que isso seja útil — passei a manhã de ontem batendo a cabeça contra a parede com isso.
É realmente uma pena, especialmente em relação ao POP, pois configurar o recebimento de e-mails vai ficar muito mais difícil, a menos que o Discourse adicione suporte a IMAP para caixas de correio de entrada.
Há uma solução simples para o recebimento de e-mails que inclui um container para recebê-los. Antigamente, era chamada de “straightforward”, mas alguém se opôs ao nome e ela foi alterada, e não consigo encontrá-la mais.
Bem, executar seu próprio servidor de e-mail deve ser considerado um recurso de último caso em qualquer situação. Acredito que era “entrega direta”, tente pesquisar por isso.