Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e94613cf
authored
Jul 26, 2024
by
Oswin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[fix] fix send email error using outlook smtp
parent
fc13e56b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
+35
-0
common/email-outlook-auth.go
+32
-0
common/email.go
+3
-0
No files found.
common/email-outlook-auth.go
0 → 100644
View file @
e94613cf
package
common
import
(
"errors"
"net/smtp"
)
type
outlookAuth
struct
{
username
,
password
string
}
func
LoginAuth
(
username
,
password
string
)
smtp
.
Auth
{
return
&
outlookAuth
{
username
,
password
}
}
func
(
a
*
outlookAuth
)
Start
(
_
*
smtp
.
ServerInfo
)
(
string
,
[]
byte
,
error
)
{
return
"LOGIN"
,
[]
byte
{},
nil
}
func
(
a
*
outlookAuth
)
Next
(
fromServer
[]
byte
,
more
bool
)
([]
byte
,
error
)
{
if
more
{
switch
string
(
fromServer
)
{
case
"Username:"
:
return
[]
byte
(
a
.
username
),
nil
case
"Password:"
:
return
[]
byte
(
a
.
password
),
nil
default
:
return
nil
,
errors
.
New
(
"unknown fromServer"
)
}
}
return
nil
,
nil
}
common/email.go
View file @
e94613cf
...
@@ -62,6 +62,9 @@ func SendEmail(subject string, receiver string, content string) error {
...
@@ -62,6 +62,9 @@ func SendEmail(subject string, receiver string, content string) error {
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
}
else
if
strings
.
HasSuffix
(
SMTPAccount
,
"outlook.com"
)
{
auth
=
LoginAuth
(
SMTPAccount
,
SMTPToken
)
err
=
smtp
.
SendMail
(
addr
,
auth
,
SMTPAccount
,
to
,
mail
)
}
else
{
}
else
{
err
=
smtp
.
SendMail
(
addr
,
auth
,
SMTPAccount
,
to
,
mail
)
err
=
smtp
.
SendMail
(
addr
,
auth
,
SMTPAccount
,
to
,
mail
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment