// Client Get SMTP Client interface.
Client Get SMTP Client interface.
// Client Get SMTP Client interface .
func (s *smtpClient) Client(ctx context.Context) (*smtp.Client, errors.Error) {
	if s.cli == nil {
		var (
			addr = s.cfg.GetHost()
			tlsc = s.tls.Clone()
		)
		if s.cfg.GetTlSServerName() != "" && s.cfg.GetNet() != NET_UNIX {
			tlsc.ServerName = s.cfg.GetTlSServerName()
		}
		if s.cfg.IsTLSSkipVerify() && s.cfg.GetNet() != NET_UNIX {
			tlsc.InsecureSkipVerify = true
		}
		if s.cfg.GetPort() > 0 {
			addr = fmt.Sprintf("%s:%v", s.cfg.GetHost(), s.cfg.GetPort())
		}
		if cli, con, err := s.tryClient(ctx, addr, tlsc); err != nil {
			return nil, err
		} else if err := s.auth(cli, addr); err != nil {
			return nil, err
		} else {
			s.Close()
			s.con = con
			s.cli = cli
		}
	}
	return s.cli, nil
}
func ( s * smtpClient ) Client ( ctx context . Context ) ( * smtp . Client , errors . Error ) { if s . cli == nil { var ( addr = s . cfg . GetHost ( ) tlsc = s . tls . Clone ( ) ) if s . cfg . GetTlSServerName ( ) != " " && s . cfg . GetNet ( ) != NET_UNIX { tlsc . ServerName = s . cfg . GetTlSServerName ( ) } if s . cfg . IsTLSSkipVerify ( ) && s . cfg . GetNet ( ) != NET_UNIX { tlsc . InsecureSkipVerify = true } if s . cfg . GetPort ( ) > 0 { addr = fmt . Sprintf ( " " , s . cfg . GetHost ( ) , s . cfg . GetPort ( ) ) } if cli , con , err := s . tryClient ( ctx , addr , tlsc ) ; err != nil { return nil , err } else if err := s . auth ( cli , addr ) ; err != nil { return nil , err } else { s . Close ( ) s . con = con s . cli = cli } } return s . cli , nil }
Client Get SMTP Client interface.
Client Get SMTP Client interface .