Debian Codegraph @

sender_explicit_tls.go

raw symbols SCIP
1 package mailyakscip-go gomod github.com/domodwyer/mailyak/v3 . `github.com/domodwyer/mailyak/v3`/
2
3 import (
4 "crypto/tlsscip-go gomod github.com/golang/go/src go1.12 `crypto/tls`/"
5 "netscip-go gomod github.com/golang/go/src go1.12 net/"
6 )
7
8 // senderExplicitTLS connects to a SMTP server over a TLS connection, performs a
9 // handshake and validation according to the provided tls.Config before sending
10 // the email.
11 type senderExplicitTLSscip-go gomod github.com/domodwyer/mailyak/v3 . `github.com/domodwyer/mailyak/v3`/senderExplicitTLS# struct {
12 hostAndPortscip-go gomod github.com/domodwyer/mailyak/v3 . `github.com/domodwyer/mailyak/v3`/senderExplicitTLS#hostAndPort. string
13 hostnamescip-go gomod github.com/domodwyer/mailyak/v3 . `github.com/domodwyer/mailyak/v3`/senderExplicitTLS#hostname. string
14
15 // tlsConfig is always non-nil
16 tlsConfigscip-go gomod github.com/domodwyer/mailyak/v3 . `github.com/domodwyer/mailyak/v3`/senderExplicitTLS#tlsConfig. *tlsscip-go gomod github.com/golang/go/src go1.12 `crypto/tls`/.Configscip-go gomod github.com/golang/go/src go1.12 `crypto/tls`/Config#
17 }
18
19 // Connect to the SMTP host configured in m, and send the email.
20 func (s *senderExplicitTLSscip-go gomod github.com/domodwyer/mailyak/v3 . `github.com/domodwyer/mailyak/v3`/senderExplicitTLS#) Sendscip-go gomod github.com/domodwyer/mailyak/v3 . `github.com/domodwyer/mailyak/v3`/senderExplicitTLS#Send().(m sendableMailscip-go gomod github.com/domodwyer/mailyak/v3 . `github.com/domodwyer/mailyak/v3`/sendableMail#) error {
21 conn, err := tlsscip-go gomod github.com/golang/go/src go1.12 `crypto/tls`/.Dialscip-go gomod github.com/golang/go/src go1.12 `crypto/tls`/Dial().("tcp", s.hostAndPortscip-go gomod github.com/domodwyer/mailyak/v3 . `github.com/domodwyer/mailyak/v3`/senderExplicitTLS#hostAndPort., s.tlsConfigscip-go gomod github.com/domodwyer/mailyak/v3 . `github.com/domodwyer/mailyak/v3`/senderExplicitTLS#tlsConfig.)
22 if err != nil {
23 return err
24 }
25 defer func() { _ = conn.Closescip-go gomod github.com/golang/go/src go1.12 `crypto/tls`/Conn#Close().() }()
26
27 // Perform the SMTP protocol conversation, using the provided TLS ServerName
28 // as the SMTP server name.
29 return smtpExchangescip-go gomod github.com/domodwyer/mailyak/v3 . `github.com/domodwyer/mailyak/v3`/smtpExchange().(m, conn, s.hostnamescip-go gomod github.com/domodwyer/mailyak/v3 . `github.com/domodwyer/mailyak/v3`/senderExplicitTLS#hostname., false)
30 }
31
32 // newSenderWithExplicitTLS constructs a new senderExplicitTLS.
33 //
34 // If tlsConfig is nil, a sensible default with maximum compatability is
35 // generated.
36 func newSenderWithExplicitTLSscip-go gomod github.com/domodwyer/mailyak/v3 . `github.com/domodwyer/mailyak/v3`/newSenderWithExplicitTLS().(hostAndPort string, tlsConfig *tlsscip-go gomod github.com/golang/go/src go1.12 `crypto/tls`/.Configscip-go gomod github.com/golang/go/src go1.12 `crypto/tls`/Config#) (*senderExplicitTLSscip-go gomod github.com/domodwyer/mailyak/v3 . `github.com/domodwyer/mailyak/v3`/senderExplicitTLS#, error) {
37 // Split the hostname from the addr.
38 //
39 // This hostname is used during TLS negotiation and during SMTP
40 // authentication.
41 hostName, _, err := netscip-go gomod github.com/golang/go/src go1.12 net/.SplitHostPortscip-go gomod github.com/golang/go/src go1.12 net/SplitHostPort().(hostAndPort)
42 if err != nil {
43 return nil, err
44 }
45
46 if tlsConfig != nil {
47 // Clone the user-provided TLS config to prevent it being
48 // mutated by the caller.
49 tlsConfig = tlsConfig.Clonescip-go gomod github.com/golang/go/src go1.12 `crypto/tls`/Config#Clone().()
50 } else {
51 // If there is no TLS config provided, initialise a default.
52 //nolint:gosec // Maximum compatability but please use TLS >= 1.2
53 tlsConfig = &tlsscip-go gomod github.com/golang/go/src go1.12 `crypto/tls`/.Configscip-go gomod github.com/golang/go/src go1.12 `crypto/tls`/Config#{
54 ServerNamescip-go gomod github.com/golang/go/src go1.12 `crypto/tls`/Config#ServerName.: hostName,
55 }
56 }
57
58 return &senderExplicitTLSscip-go gomod github.com/domodwyer/mailyak/v3 . `github.com/domodwyer/mailyak/v3`/senderExplicitTLS#{
59 hostAndPortscip-go gomod github.com/domodwyer/mailyak/v3 . `github.com/domodwyer/mailyak/v3`/senderExplicitTLS#hostAndPort.: hostAndPort,
60 hostnamescip-go gomod github.com/domodwyer/mailyak/v3 . `github.com/domodwyer/mailyak/v3`/senderExplicitTLS#hostname.: hostName,
61
62 tlsConfigscip-go gomod github.com/domodwyer/mailyak/v3 . `github.com/domodwyer/mailyak/v3`/senderExplicitTLS#tlsConfig.: tlsConfig,
63 }, nil
64 }