mirror of
https://github.com/coaidev/coai.git
synced 2025-05-21 22:10:12 +09:00
chore: Compatible with pre-modified SMTP sending method (#174)
This commit is contained in:
parent
6f3cdad1e7
commit
16aba18926
@ -289,9 +289,7 @@ function Mail({ data, dispatch, onChange }: CompProps<MailState>) {
|
|||||||
data.port < 65535 &&
|
data.port < 65535 &&
|
||||||
data.username.length > 0 &&
|
data.username.length > 0 &&
|
||||||
data.password.length > 0 &&
|
data.password.length > 0 &&
|
||||||
data.from.length > 0 &&
|
data.from.length > 0
|
||||||
data.username.includes("@") &&
|
|
||||||
!/\w+@/.test(data.from)
|
|
||||||
);
|
);
|
||||||
}, [data]);
|
}, [data]);
|
||||||
|
|
||||||
@ -391,7 +389,6 @@ function Mail({ data, dispatch, onChange }: CompProps<MailState>) {
|
|||||||
}
|
}
|
||||||
className={cn(
|
className={cn(
|
||||||
"transition-all duration-300",
|
"transition-all duration-300",
|
||||||
!data.username.includes("@") && `border-red-700`,
|
|
||||||
)}
|
)}
|
||||||
placeholder={t("admin.system.mailUser")}
|
placeholder={t("admin.system.mailUser")}
|
||||||
/>
|
/>
|
||||||
@ -426,9 +423,6 @@ function Mail({ data, dispatch, onChange }: CompProps<MailState>) {
|
|||||||
placeholder={`${data.username}@${location.hostname}`}
|
placeholder={`${data.username}@${location.hostname}`}
|
||||||
className={cn(
|
className={cn(
|
||||||
"transition-all duration-300",
|
"transition-all duration-300",
|
||||||
data.from.length > 0 &&
|
|
||||||
!/\w+@/.test(data.from) &&
|
|
||||||
`border-red-700`,
|
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</ParagraphItem>
|
</ParagraphItem>
|
||||||
|
@ -38,10 +38,19 @@ func (s *SmtpPoster) SendMail(to string, subject string, body string) error {
|
|||||||
return fmt.Errorf("smtp not configured properly")
|
return fmt.Errorf("smtp not configured properly")
|
||||||
}
|
}
|
||||||
|
|
||||||
dialer := mail.NewDialer(s.Host, s.Port, s.Username, s.Password)
|
var dialer *mail.Dialer
|
||||||
message := mail.NewMessage()
|
var from string
|
||||||
|
|
||||||
message.SetHeader("From", s.From)
|
if strings.Contains(s.Username, "@") {
|
||||||
|
dialer = mail.NewDialer(s.Host, s.Port, s.Username, s.Password)
|
||||||
|
from = s.From
|
||||||
|
} else {
|
||||||
|
dialer = mail.NewDialer(s.Host, s.Port, s.From, s.Password)
|
||||||
|
from = fmt.Sprintf("%s <%s>", s.Username, s.From)
|
||||||
|
}
|
||||||
|
|
||||||
|
message := mail.NewMessage()
|
||||||
|
message.SetHeader("From", from)
|
||||||
message.SetHeader("To", to)
|
message.SetHeader("To", to)
|
||||||
message.SetHeader("Subject", subject)
|
message.SetHeader("Subject", subject)
|
||||||
message.SetBody("text/html", body)
|
message.SetBody("text/html", body)
|
||||||
|
Loading…
Reference in New Issue
Block a user