| 205 | } |
| 206 | |
| 207 | func (p *Pool) build() (*client, error) { |
| 208 | cl, err := smtp.Dial(p.addr) |
| 209 | if err != nil { |
| 210 | return nil, err |
| 211 | } |
| 212 | |
| 213 | // Is there a custom hostname for doing a HELLO with the SMTP server? |
| 214 | if p.helloHostname != "" { |
| 215 | cl.Hello(p.helloHostname) |
| 216 | } |
| 217 | |
| 218 | c := &client{cl, 0} |
| 219 | |
| 220 | if _, err := startTLS(c, p.tlsConfig); err != nil { |
| 221 | c.Close() |
| 222 | return nil, err |
| 223 | } |
| 224 | |
| 225 | if p.auth != nil { |
| 226 | if _, err := addAuth(c, p.auth); err != nil { |
| 227 | c.Close() |
| 228 | return nil, err |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | return c, nil |
| 233 | } |
| 234 | |
| 235 | func (p *Pool) maybeReplace(err error, c *client) { |
| 236 | if err == nil { |