mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 01:04:25 +08:00
modify text and field name
This commit is contained in:
@@ -18,23 +18,23 @@ type DefaultMailer struct {
|
||||
}
|
||||
|
||||
// NewDefaultMailer returns a new default mailer
|
||||
func NewDefaultMailer(smtpConfig *settings.SmtpConfig) (*DefaultMailer, error) {
|
||||
host, portStr, err := net.SplitHostPort(smtpConfig.SmtpHost)
|
||||
func NewDefaultMailer(smtpConfig *settings.SMTPConfig) (*DefaultMailer, error) {
|
||||
host, portStr, err := net.SplitHostPort(smtpConfig.SMTPHost)
|
||||
|
||||
if err != nil {
|
||||
return nil, errs.ErrSmtpServerHostInvalid
|
||||
return nil, errs.ErrSMTPServerHostInvalid
|
||||
}
|
||||
|
||||
port, err := utils.StringToInt(portStr)
|
||||
|
||||
if err != nil {
|
||||
return nil, errs.ErrSmtpServerHostInvalid
|
||||
return nil, errs.ErrSMTPServerHostInvalid
|
||||
}
|
||||
|
||||
dialer := mail.NewDialer(host, port, smtpConfig.SmtpUser, smtpConfig.SmtpPasswd)
|
||||
dialer := mail.NewDialer(host, port, smtpConfig.SMTPUser, smtpConfig.SMTPPasswd)
|
||||
dialer.TLSConfig = &tls.Config{
|
||||
ServerName: host,
|
||||
InsecureSkipVerify: smtpConfig.SmtpSkipTLSVerify,
|
||||
InsecureSkipVerify: smtpConfig.SMTPSkipTLSVerify,
|
||||
}
|
||||
|
||||
mailer := &DefaultMailer{
|
||||
@@ -48,7 +48,7 @@ func NewDefaultMailer(smtpConfig *settings.SmtpConfig) (*DefaultMailer, error) {
|
||||
// SendMail sends an email according to argument
|
||||
func (m *DefaultMailer) SendMail(message *MailMessage) error {
|
||||
if m.dialer == nil {
|
||||
return errs.ErrSmtpServerNotEnabled
|
||||
return errs.ErrSMTPServerNotEnabled
|
||||
}
|
||||
|
||||
mailMessage := mail.NewMessage()
|
||||
|
||||
@@ -16,12 +16,12 @@ var (
|
||||
|
||||
// InitializeMailer initializes the current mailer according to the config
|
||||
func InitializeMailer(config *settings.Config) error {
|
||||
if !config.EnableSmtp {
|
||||
if !config.EnableSMTP {
|
||||
Container.Current = nil
|
||||
return nil
|
||||
}
|
||||
|
||||
mailer, err := NewDefaultMailer(config.SmtpConfig)
|
||||
mailer, err := NewDefaultMailer(config.SMTPConfig)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user