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.
Utilizzo socketlabs.com come servizio di consegna email e ho riscontrato un problema simile. Nel mio caso, la soluzione è stata modificare lib/tasks/emails.rake come segue:
Modificare la riga: Net::SMTP.start(smtp[:address], smtp[:port], 'localhost', smtp[:user_name], smtp[:password])
in Net::SMTP.start(smtp[:address], smtp[:port], 'localhost', smtp[:user_name], smtp[:password], smtp[:authentication])
Senza questa modifica, DISCOURSE_SMTP_AUTHENTICATION: login non viene passato al codice SMTP di livello inferiore.
Non ho testato se il codice modificato funzioni ancora per altri metodi di autenticazione, ma risolve il problema per l’autenticazione login.
Posso confermare che l’aggiunta di smtp[:authentication]
alla chiamata Net::SMTP.start e l’impostazione di DISCOURSE_SMTP_AUTHENTICATION: login
in app.yml risolvono il problema nella pagina di test delle email.
Credo che le email regolari vengano inviate tramite la libreria mail, e che impostare DISCOURSE_SMTP_AUTHENTICATION: login
in app.yml sia sufficiente per far funzionare correttamente la libreria.
Tuttavia, ritengo che lib/tasks/emails.rake dovrebbe essere corretto per utilizzare l’impostazione DISCOURSE_SMTP_AUTHENTICATION. Questo eviterebbe qualche inutile attività di debug.
Come aggiornamento generale su questo problema, Microsoft sta procedendo alla rimozione dell’autenticazione legacy per SMTP e POP3, il che renderà le cose più difficili se utilizzi O365 come provider di posta. La policy applicata di default ora è quella di disabilitare SMTP AUTH e devi abilitarla per ogni casella di posta. Spero che sia utile — ho passato ieri mattina a sbattermi la testa contro questo muro.
È un vero peccato, in particolare per POP, perché configurare la posta in arrivo diventerà molto più complicato a meno che Discourse non aggiunga il supporto IMAP per le caselle di posta in arrivo.
Esiste una soluzione semplice per la posta in arrivo che include un contenitore per riceverla. In passato si chiamava “semplice”, ma qualcuno ha fatto obiezione al nome e l’hanno cambiato, e ora non riesco più a trovarlo.
Beh, in ogni caso, gestire il proprio server di posta dovrebbe essere considerato un’ultima risorsa. Credo si trattasse di “consegna diretta”, prova a cercare quel termine.