Open stevedomin opened 8 years ago
Can you say what the special character is?
You could try something like this:
AuthString = base64:encode(io_lib:format("\0~s\0~s", [Username, Password])),
To replace this line:
https://github.com/Vagabond/gen_smtp/blob/master/src/gen_smtp_client.erl#L404
I mean
I'm getting the following error:
** (ArithmeticError) bad argument in arithmetic expression
(stdlib) base64.erl:81: :base64.encode_l/1
(stdlib) base64.erl:67: :base64.encode/1
(gen_smtp) src/gen_smtp_client.erl:400: :gen_smtp_client.do_AUTH_each/4
(gen_smtp) src/gen_smtp_client.erl:322: :gen_smtp_client.try_AUTH/3
(gen_smtp) src/gen_smtp_client.erl:203: :gen_smtp_client.do_smtp_session/3
(gen_smtp) src/gen_smtp_client.erl:142: :gen_smtp_client.try_smtp_sessions/4
The password was generated by 1Password so it contains /
, %
and )
Sorry, I should have tested it. Try this:
AuthString = base64:encode(list_to_binary(io_lib:format("\0~s\0~s", [Username, Password]))),
It's now rejecting the password twice and then I get an error tuple:
password rejected: 535 Authentication failed: Bad username / password
password rejected: 535 Authentication failed: Bad username / password
{:error, :retries_exceeded,
{:network_failure, "smtp.sendgrid.net", {:error, :closed}}}
Is it possible to give me a credential on your account for testing?
You can create a free account at https://sendgrid.com/, comes with 12k emails free.
That's probably the simplest, otherwise happy to figure out a way to give you credentials (pgp?)
I will give it a try.
Ugh, they want to validate my 'company' and a bunch of other nonsense, which I don't really have.
Ah crap, do you have a pgp key (or a keybase.io account)?
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v2
mQENBFSz/scBCADF0IVZU2w9Qqh6Mi1T/K1a6v8P4Qx4mhi6hx3yJizJzH7b3HlT
CEBYSqoeO/X1PxMV1xBjO4m5XhyUq0/MpvJtxwjRNItsWKF68TXVyqkhSUiDFCfS
EUMdIwLt26+uKzfeiYkNOAfj9hc+NQNNqliJO2GBOmB71I0JuUZRdkzUytb/zF8z
HJolOiSBTtZGAKLYZ7Cfv/w+pR0UcgDlyOxNGfrH6GgisI4h+IQc/qkPLnZ8U78O
zrEQkE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x1S5XTYErRFbKeYzCUThLpTNEZvmbbvtyP
pnLiGcnaaii+pZ+f8lxL7Mz3T8pJCjsY/cmi0PDwEwwtOaNFrXJSJPZJ6MzuFzte
HkWkdlHlsweOfZiZlh7Li8V+oUwVCkYM57ZB1bb4pzDmhDcBiaMYofK4FweHdhyy
GGsTdxJFJmsWrEDEp9ckOcR0NR61TNhPwb9JncJZwCtr+isR6F71sN1vg7VP7LyQ
Evu8JiiLkeHc0NZnIZO+9nXHJEURjkcTxAu/NDjuZoFT
=budR
-----END PGP PUBLIC KEY BLOCK-----
Ok, so I got the credentials, but I can't authenticate to their SMTP server with the credentials using their example here:
I get the same Bad username / password
error
Ok, my sendgrid account got activated (I have no idea why).
If I use the username for the account. not the email address, I can authenticate and send via sendgrid.
Ok, this was indeed the issue in my case (I created some testing credentials with a password without special characters, so I thought this was the issue).
Do you think we could make the error message that gen_stmp
gives better? In the current form you need to manually uncomment logging statement directly in the code to figure out what's happening.
Yeah, that is a legitimate concern.
I tried to reproduce your original error with the 'argument' error, but I could not, we should fix that too.
** (ArgumentError) argument error
:erlang.++("username", [0 | "passwordwithspecialcharacter"])
I was able to reproduce this using a binary (default for Elixir) instead of a char list for Username
and Password
arguments.
@keichan34 looking at the current code I suspect your issue has been resolved.
@stevedomin Is this still a problem?
In general: we could add a flag to enable the logging of all client/server communication for a specific request.
While attempting to send through my Sendgrid account I got stuck on this error for ages. Basically my password had some special characters and I guess I needed to do some escaping, unfortunately the error reported wasn't helpful at all.
I'm wondering if these anything we can do to show a more meaningful error to the user. I'm more than happy to contribute, but I'll need some guidance.
I had to uncomment some logging to figure out the issue (see logs below).
(This is elixir, not erlang, sorry about that)