forked from drew/smtprelay
Remove separate remote_port config value and add it to remote_host
This commit is contained in:
11
main.go
11
main.go
@@ -3,8 +3,8 @@ package main
|
|||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
|
||||||
"log"
|
"log"
|
||||||
|
"net"
|
||||||
"net/smtp"
|
"net/smtp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -20,17 +20,18 @@ var (
|
|||||||
localCert = flag.String("local_cert", "", "SSL certificate for STARTTLS/TLS")
|
localCert = flag.String("local_cert", "", "SSL certificate for STARTTLS/TLS")
|
||||||
localKey = flag.String("local_key", "", "SSL private key 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)")
|
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")
|
remoteHost = flag.String("remote_host", "smtp.gmail.com:587", "Outgoing SMTP server")
|
||||||
remotePort = flag.Int("remote_port", 587, "Outgoing SMTP port")
|
|
||||||
remoteUser = flag.String("remote_user", "", "Username for authentication on 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")
|
remotePass = flag.String("remote_pass", "", "Password for authentication on outgoing SMTP server")
|
||||||
)
|
)
|
||||||
|
|
||||||
func handler(peer smtpd.Peer, env smtpd.Envelope) error {
|
func handler(peer smtpd.Peer, env smtpd.Envelope) error {
|
||||||
|
|
||||||
|
host, _, _ := net.SplitHostPort(*remoteHost)
|
||||||
|
|
||||||
return smtp.SendMail(
|
return smtp.SendMail(
|
||||||
fmt.Sprintf("%s:%d", *remoteHost, *remotePort),
|
*remoteHost,
|
||||||
smtp.PlainAuth("", *remoteUser, *remotePass, *remoteHost),
|
smtp.PlainAuth("", *remoteUser, *remotePass, host),
|
||||||
env.Sender,
|
env.Sender,
|
||||||
env.Recipients,
|
env.Recipients,
|
||||||
env.Data,
|
env.Data,
|
||||||
|
|||||||
@@ -24,16 +24,13 @@
|
|||||||
; Relay all mails to this SMTP server
|
; Relay all mails to this SMTP server
|
||||||
|
|
||||||
; GMail
|
; GMail
|
||||||
;remote_host = smtp.gmail.com
|
;remote_host = smtp.gmail.com:587
|
||||||
;remote_port = 587
|
|
||||||
|
|
||||||
; Mailgun.org
|
; Mailgun.org
|
||||||
;remote_host = smtp.mailgun.org
|
;remote_host = smtp.mailgun.org:587
|
||||||
;remote_port = 587
|
|
||||||
|
|
||||||
; Mailjet.com
|
; Mailjet.com
|
||||||
;remote_host = in-v3.mailjet.com
|
;remote_host = in-v3.mailjet.com:587
|
||||||
;remote_port = 465
|
|
||||||
|
|
||||||
; Authentication credentials on outgoing SMTP server
|
; Authentication credentials on outgoing SMTP server
|
||||||
;remote_user =
|
;remote_user =
|
||||||
|
|||||||
Reference in New Issue
Block a user