mirror of
https://github.com/decke/smtprelay.git
synced 2025-12-25 15:52:29 -07:00
Improve logging for received emails
This commit is contained in:
9
main.go
9
main.go
@@ -114,6 +114,13 @@ func authChecker(peer smtpd.Peer, username string, password string) error {
|
||||
}
|
||||
|
||||
func mailHandler(peer smtpd.Peer, env smtpd.Envelope) error {
|
||||
peerIP := ""
|
||||
if addr, ok := peer.Addr.(*net.TCPAddr); ok {
|
||||
peerIP = addr.IP.String()
|
||||
}
|
||||
|
||||
log.Printf("new mail from=<%s> to=%s peer=[%s]\n", env.Sender,
|
||||
env.Recipients, peerIP)
|
||||
|
||||
var auth smtp.Auth
|
||||
host, _, _ := net.SplitHostPort(*remoteHost)
|
||||
@@ -124,6 +131,8 @@ func mailHandler(peer smtpd.Peer, env smtpd.Envelope) error {
|
||||
|
||||
env.AddReceivedLine(peer)
|
||||
|
||||
log.Printf("delivering using smarthost %s\n", *remoteHost)
|
||||
|
||||
return smtp.SendMail(
|
||||
*remoteHost,
|
||||
auth,
|
||||
|
||||
Reference in New Issue
Block a user