Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow sending mails without authentication #36

Closed
kolaente opened this issue Aug 2, 2022 · 6 comments
Closed

Allow sending mails without authentication #36

kolaente opened this issue Aug 2, 2022 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@kolaente
Copy link
Sponsor

kolaente commented Aug 2, 2022

Is your feature request related to a problem? Please describe.

There are users who run their smtp servers without authentication (for example in a private network). Currently, this package is unable to connect to such mail servers.

I've tried a few things and got different error messages as a result:

  1. With auth type plain and no username/password:
dial failed: SMTP AUTH failed: 535 Incorrect authentication data
  1. Without the mail.WithSMTPAuth option or uncommenting https://github.com/wneessen/go-mail/blob/main/client.go#L327-L329:
send failed: sending RCPT TO command failed: 550 relay not permitted
  1. With an empty password and username.

None of these three things seem to work.

Related go-vikunja/vikunja#34 (comment)

Describe the solution you'd like

Ideally, there would be an option like mail.WithoutAuthentication which does not even try to authenticate and instead just sends the mail straight away. I thought this would work when removing lines https://github.com/wneessen/go-mail/blob/main/client.go#L327-L329 but it didn't.

Describe alternatives you've considered

No response

Additional context

No response

@kolaente kolaente added the enhancement New feature or request label Aug 2, 2022
@wneessen
Copy link
Owner

wneessen commented Aug 3, 2022

Hi, thanks for the request.

This is actually a false-positive. When used without the mail.WithSMTPAuth option, the library in fact does send mails without any authentication - if the mail server allows this.

As you stated in 2. the 550 relay not permitted message means, that the mail server does not allow relaying mails - meaning sending mails without being either authenticated or being IP whitelisted. I just confirmed with my local Postfix installation, that I am able to send mails without prior authentication.

I suggest that you check the local mail server configuration to see if local relaying is allowed or not.
In Postfix you can accomplish this by

mynetworks = 127.0.0.0/8
smtpd_recipient_restrictions = permit_mynetworks [....]

@wneessen wneessen self-assigned this Aug 3, 2022
@kolaente
Copy link
Sponsor Author

kolaente commented Aug 3, 2022

Thanks for the explanation! Looks like my lack of mail server knowledge is to blame here :)

I've checked the implementation and config again and it seems to work fine when I run everything on a server that's allowed to talk to the mail server.

@kolaente kolaente closed this as completed Aug 3, 2022
@mitar
Copy link

mitar commented Feb 19, 2024

I also got confused how to configure no-authentication SMTP. Luckily I found this issue.

@wneessen
Copy link
Owner

Gald this helped you. I'll consider adding a FAQ section to the go-mail website and adding this, as it seems a common issue.

@mitar
Copy link

mitar commented Feb 20, 2024

Maybe easier is to define SMTPAuthType None which equals to an empty string. This is what I did in my own codebase now.

@wneessen
Copy link
Owner

Gotta evaluate that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants