1
0
mirror of https://github.com/chylex/SMTP-Relay.git synced 2024-12-04 14:42:49 +01:00
Commit Graph

70 Commits

Author SHA1 Message Date
Bernhard Froehlich
cc064e497e
command: Add some environment variables when calling external cmd 2023-01-20 09:31:09 +00:00
Bernhard Froehlich
e3ba45ede2
Fix output for "-version" to not contain unneccessary noise 2022-05-23 15:07:21 +00:00
Javi
b134e426d7
Propagate the error to the client if the external command fails (#40)
This change makes the external command code return a generic 554 error to the SMTP client if the external command fails, so it knows sending failed and can retry.
2022-04-25 15:52:12 +02:00
Mark Gardner
4221919689 Allow config to have multiple remotes.
This will enable development teams to test emails from
a system like mailcatcher while also having the email
delivered to the indented mailbox.
2022-04-21 10:52:03 -05:00
Rubin Raithel
016ef762fb
add: basic smtpd configuration options 2022-01-10 20:39:55 +01:00
Ben Ubois
3f627d3281 Move AddReceivedLine before further processing. 2021-05-08 11:56:28 -07:00
Ben Ubois
d8860fc917 Added external command support. 2021-05-07 14:08:10 -07:00
Bernhard Froehlich
441a53cfd9
Fix code formatting with gofmt -s 2021-04-03 19:00:38 +00:00
Jonathon Reinhart
45a676e274 Add localAuthRequired() helper function
This just makes the configuration state a little more obvious.
2021-04-01 01:12:34 -04:00
Jonathon Reinhart
ca1ccd85e3 Refactor parsing of -listen string out into separate config function
This makes the "for each listen address" loop in main() look even cleaner.
2021-04-01 01:12:34 -04:00
Jonathon Reinhart
1b7b551f65 Handle signals and gracefully shut down server 2021-04-01 01:07:30 -04:00
Jonathon Reinhart
22ef0c2ee6 Move SMTP auth setup to ConfigLoad()
This has several benefits:
- Configuration errors are caught at startup rather than upon a connection
- mailHandler() has less work to do for each connection

Rather than relying on remote_user and remote_pass to control whether
authentication is used, introduce an explicit "none" type for
remote_auth, and make that the default. (This is effectively the same
default behavior since remote_user and remote_pass default to empty.)

Also, we are in a better position to more thoroughly check for
configuration errors or mismatches:
- If remote_auth is given, remote_user and remote_pass are required.
- If remote_auth is given, remote_host is also required (because it
  makes no sense to say we're going to authenticate if we have no server
  to which to authenticate.)
- If remote_user or remote_pass are given, remote_auth cannot be "none".
2021-03-14 18:41:54 -04:00
Jonathon Reinhart
7c0ba34025 Move compilation of allowed_recipients to ConfigLoad()
This has several benefits:
- Configuration errors are caught at startup rather than upon a connection
- recipientChecker() has less work to do for each connection
2021-03-14 12:31:38 -04:00
Jonathon Reinhart
a896ab2847 Move compilation of allowed_sender to ConfigLoad()
This has several benefits:
- Configuration errors are caught at startup rather than upon a connection
- senderChecker() has less work to do for each connection
2021-03-14 12:31:38 -04:00
Jonathon Reinhart
0503c12ccd Allow "allowed_nets" to be empty, meaning any network is allowed 2021-03-13 20:34:48 -05:00
Jonathon Reinhart
ef3f9c8ea0 Move parsing of "allowed_nets" out to ConfigLoad()
This has several benefits:
- Configuration errors are caught at startup rather than upon a connection
- connectionChecker() has less work to do for each connection
2021-03-13 20:34:48 -05:00
Jonathon Reinhart
4036213dd5 Simplify peerIP determination in connectionChecker()
peerIP = net.ParseIP(addr.IP.String())

can be simplified to just:

    peerIP = addr.IP

but we can also skip the safe cast since we know the net.Addr will always
be net.TCPAddr because we only have TCP listeners.
2021-03-13 20:19:07 -05:00
Jonathon Reinhart
20ca816160 Discard mail if remote_host is not set
This is useful for test environments.
2021-03-13 09:28:04 -05:00
Jonathon Reinhart
34cb47c364 Implement structured logs using logrus
This was based loosely on an earlier implementation by
Danny Kopping <danny.kopping@grafana.com>
2021-03-13 03:25:57 -05:00
Bernhard Froehlich
5ba64c5c6e
Add new Release Workflow using Github Actions and wangyoucao577/go-release-action 2021-02-17 12:49:24 +00:00
Bernhard Froehlich
fefeccec39
Remove weak CBC cipher suites and bump minimum TLS version to TLS 1.2 2021-02-16 15:31:53 +00:00
Jonathon Reinhart
70dfe6b128 Only call AuthLoadFile() once at startup 2021-02-15 00:08:37 -05:00
Jonathon Reinhart
7fa0eebf95 Simplify range code for setting up listeners 2021-02-15 00:00:38 -05:00
Jonathon Reinhart
ecf830865c Add helpful log messages for various error cases 2021-02-14 23:49:17 -05:00
Jonathon Reinhart
4fd6bb1004 Refactor common code in listener setup 2021-02-14 23:30:31 -05:00
Jonathon Reinhart
fd3f513b18 Don't run ListenAndServe in a goroutine
Any errors returned in ListenAndServe() (e.g. port already in use) will be
swallowed and not evident to the user.
2021-02-14 23:24:25 -05:00
Jonathon Reinhart
b202a2209e Refactor out getTLSConfig() 2021-02-14 23:21:42 -05:00
Jonathon Reinhart
0e8986ca79
Expand allowedUsers email field to support comma-separated and domains (#9)
* Expand allowedUsers email field to support comma-separated and domains

Closes #8

* Refactor AuthFetch() to return AuthUser struct

Also, this breaks out a parseLine() function which can be easily tested.

* Ignore empty addrs after splitting commas

This ignores a trailing comma

* Add tests for auth parseLine()

* Update documentation in smtprelay.ini

* Fix bug where addrAllowed() was incorrectly case-sensitive

* Update allowedUsers allowed domain format to require leading @

This disambiguates a local user ('john.smith') from a domain ('example.com')
2021-02-14 22:16:18 +01:00
Jonathon Reinhart
f33105f83c Allow email field to be empty in allowedUsers file
In this case, it is not checked.
2021-02-09 00:00:36 -05:00
Bernhard Froehlich
6f3bd16988
The check if authentication was properly done is redundant now as of smtpd v0.2.0
See:	32be721d71
2020-06-07 17:17:28 +00:00
Bernhard Froehlich
53c2c27647
Support LOGIN authentication on outgoing SMTP server
PR:		#1
Obtained from:	https://gist.github.com/andelf/5118732
2020-05-15 21:08:17 +00:00
Bernhard Froehlich
00b96161b3
Remove duplication of TLS cipher suites for tls:// and startssl:// 2020-05-11 13:52:25 +00:00
Bernhard Froehlich
324585c63c
Update list of cipher suites and add ciphers for TLS 1.3 2020-03-02 10:45:02 +00:00
Carlos Alberto Costa Beppler
0b65e904d8 Allows specify the sender used on SMTP conversation with outgoing server. 2019-09-06 17:07:37 -03:00
Bernhard Froehlich
770e819e2b
Improve error checking 2019-02-21 08:29:49 +00:00
Bernhard Froehlich
d11f8d81ea
Fix formatting 2019-02-21 08:27:12 +00:00
Bernhard Froehlich
6270d75571
Improve TLS Config to prefer server ciphers, remove 3DES ciphers and require TLS 1.1 or higher 2019-01-08 15:09:29 +00:00
Bernhard Froehlich
b9d1663a18
Fixes for new authentication code 2019-01-07 11:52:25 +00:00
Bernhard Froehlich
3a96014c70
Revert package renaming 2018-12-29 13:08:10 +00:00
Bernhard Froehlich
ade7cbca36
Rename to smtprelay 2018-12-29 12:39:56 +00:00
Bernhard Froehlich
ab341c697d
Code refactoring and rename package 2018-12-29 12:24:32 +00:00
Bernhard Froehlich
a82b0faf96
Check sender email against auth file when user is authenticated 2018-12-28 15:30:55 +00:00
Bernhard Froehlich
76a04a2001
Authentication checker converted to store passwords as bcrypt hashes 2018-12-28 15:18:50 +00:00
Bernhard Froehlich
0df376e54a
Bump to 1.1.1-dev 2018-12-26 21:20:51 +00:00
Bernhard Froehlich
c05e5779a8
Bump version to 1.1.0 2018-12-26 21:07:01 +00:00
Bernhard Froehlich
571e9ea942
Fork net/smtp package 2018-12-26 20:10:19 +00:00
Bernhard Froehlich
38aa14ddbf
Ensure that authentication was successfull before we relay mails 2018-12-26 19:35:38 +00:00
Bernhard Froehlich
72dad9fb70
Handle error cases for user supplied regexp 2018-12-21 14:10:34 +00:00
Bernhard Froehlich
a0e357c0de
Add log message for successful delivery 2018-12-21 09:09:41 +00:00
Bernhard Froehlich
3d648a2ce7
Adjust SMTP error codes and messages to be aligned with the RFCs 2018-12-21 09:06:22 +00:00