2
0
forked from drew/smtprelay

Remove separate remote_port config value and add it to remote_host

This commit is contained in:
Bernhard Froehlich
2018-12-12 08:37:44 +00:00
parent b53d620dd5
commit ba30ddd83c
2 changed files with 9 additions and 11 deletions

11
main.go
View File

@@ -3,8 +3,8 @@ package main
import (
"crypto/tls"
"flag"
"fmt"
"log"
"net"
"net/smtp"
"strings"
"time"
@@ -20,17 +20,18 @@ var (
localCert = flag.String("local_cert", "", "SSL certificate for STARTTLS/TLS")
localKey = flag.String("local_key", "", "SSL private key for STARTTLS/TLS")
localForceTLS = flag.Bool("local_forcetls", false, "Force STARTTLS (needs local_cert and local_key)")
remoteHost = flag.String("remote_host", "smtp.gmail.com", "Outgoing SMTP server")
remotePort = flag.Int("remote_port", 587, "Outgoing SMTP port")
remoteHost = flag.String("remote_host", "smtp.gmail.com:587", "Outgoing SMTP server")
remoteUser = flag.String("remote_user", "", "Username for authentication on outgoing SMTP server")
remotePass = flag.String("remote_pass", "", "Password for authentication on outgoing SMTP server")
)
func handler(peer smtpd.Peer, env smtpd.Envelope) error {
host, _, _ := net.SplitHostPort(*remoteHost)
return smtp.SendMail(
fmt.Sprintf("%s:%d", *remoteHost, *remotePort),
smtp.PlainAuth("", *remoteUser, *remotePass, *remoteHost),
*remoteHost,
smtp.PlainAuth("", *remoteUser, *remotePass, host),
env.Sender,
env.Recipients,
env.Data,

View File

@@ -24,16 +24,13 @@
; Relay all mails to this SMTP server
; GMail
;remote_host = smtp.gmail.com
;remote_port = 587
;remote_host = smtp.gmail.com:587
; Mailgun.org
;remote_host = smtp.mailgun.org
;remote_port = 587
;remote_host = smtp.mailgun.org:587
; Mailjet.com
;remote_host = in-v3.mailjet.com
;remote_port = 465
;remote_host = in-v3.mailjet.com:587
; Authentication credentials on outgoing SMTP server
;remote_user =