Not able to integrate with sendgrid

Hi,

I’m trying to use Sendgrid email service and keep getting this error in the logs

Job exception: 535 Authentication failed: Bad username / password

I’m not sure what I’m doing wrong, here’s how my configuration looks like

 DISCOURSE_SMTP_ADDRESS: smtp.sendgrid.net
 DISCOURSE_SMTP_PORT: 587
 DISCOURSE_SMTP_USER_NAME: apiKey
 DISCOURSE_SMTP_PASSWORD: 'SG.xxxx.xxxxxx.xxxx'

I’ve also tried to use port 2525 on the suggestion of Fresh install. Works. Sendgrid not sending emails - #5 by Ham , but that didn’t work either.

I’m able to establish a connection using telnet.

Can someone please help? Any idea what I could be doing wrong?

From the same server that your Discourse is on?

Apologies if this is a silly question but is your SendGrid username actually: apiKey

:thinking:

I only ask, as it’s an unusual choice of account name…

Yes

No, I don’t think there’s a concept of username in sendgrid, I just followed the documentation here discourse/docs/INSTALL-email.md at main · discourse/discourse · GitHub

I might be wrong also, but I don’t see any username info in my sendgrid account.

They use different terminology but you’re still connecting to what is essentially a standard SMTP server, which will require authentication.

Go to the Teammates section - https://app.sendgrid.com/settings/teammates

In there you will see the account details that are able to send email:

The value in the “Username” column is what you need to enter in the Discourse setting DISCOURSE_SMTP_USER_NAME

So if the “Username” was SK2019 then you’d have something like:

DISCOURSE_SMTP_ADDRESS: smtp.sendgrid.net
DISCOURSE_SMTP_PORT: 587
DISCOURSE_SMTP_USER_NAME: SK2019
DISCOURSE_SMTP_PASSWORD: 'xxxx.xxxxxx.xxxx'

I tried that but didn’t work. The Sendgrid docs mention to use apiKey as username, but that doesn’t seem to be working.

Maybe I should reach out to the sendgrid team and seek their help.

Did you use apiKey when using telnet?

Yes, I followed instructions at How to send an Email with SMTP | SendGrid Docs | Twilio and they worked! Not sure what am I missing in discourse configuration.

Do the four lines in your config file look like mine (above)?

With the correct DISCOURSE_SMTP_USER_NAME that matches the one displayed in your Teammates page on SendGrid?

Yes, the username is the one displayed in the the Teammates page, the password is the key I generated (telnet works using this key), and other two fields are exactly the same.

May I know what version of discourse are you using, I’m using beta, I suspect that could be the issue.

Anyways, I’m planning to switching to mailgun, I tried it today, and it works seamlessly (though it’s expensive, but have no other options atm)

참고로 @Satwik_Kansal, 저희 Sendgrid API 사용자 이름은 "apiKey"가 아니라 "apikey"입니다. 잘 작동하고 있습니다.

같은 문제를 겪고 있습니다. 핵심만 간단히 알려주실 수 있나요? "apikey"를 사용해야 하는 건가요(동작하지 않음)? 아니면 팀원을 추가해야 하는 건가요(빈 상태임)?

기록을 위해 말씀드리면, 문서가 이 부분을 꽤 혼란스럽게 작성하고 있으며, 이 문제를 검색해 해결책을 찾으려 한 것은 이번이 처음이 아닙니다.

현재 문서에는 다음과 같이 적혀 있습니다:

SendGrid — 30일 무료 체험으로 4만 건의 이메일

SMTP 서버 주소? smtp.sendgrid.net
SMTP 사용자 이름?      apikey
SMTP 비밀번호?       [SendGrid API 키]

수정: 사람들이 혼란을 겪는 이유는 (저처럼) 'apikey’라는 항목에 자신의 API 키를 입력해야 한다고 생각하기 때문인데, 실제로는 그대로 두어야 합니다!

정말 황당하죠?

이 때문에 시도해 본 사람들의 99%가 혼란을 겪었을 것 같습니다 :confused:

(나도 당시에는 그랬습니다)