Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
52d153da
Commit
52d153da
authored
Jul 22, 2014
by
astaxie
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #710 from francoishill/patch-8
Update smtp.go (develop branch)
parents
91ee42ce
6ce55e88
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
6 deletions
+14
-6
smtp.go
logs/smtp.go
+14
-6
No files found.
logs/smtp.go
View file @
52d153da
...
@@ -54,6 +54,18 @@ func (s *SmtpWriter) Init(jsonconfig string) error {
...
@@ -54,6 +54,18 @@ func (s *SmtpWriter) Init(jsonconfig string) error {
return
nil
return
nil
}
}
func
(
s
*
SmtpWriter
)
GetSmtpAuth
(
host
string
)
smtp
.
Auth
{
if
len
(
strings
.
Trim
(
s
.
Username
,
" "
))
==
0
&&
len
(
strings
.
Trim
(
s
.
Password
,
" "
))
==
0
{
return
nil
}
return
smtp
.
PlainAuth
(
""
,
s
.
Username
,
s
.
Password
,
host
,
)
}
// write message in smtp writer.
// write message in smtp writer.
// it will send an email with subject and only this message.
// it will send an email with subject and only this message.
func
(
s
*
SmtpWriter
)
WriteMsg
(
msg
string
,
level
int
)
error
{
func
(
s
*
SmtpWriter
)
WriteMsg
(
msg
string
,
level
int
)
error
{
...
@@ -64,12 +76,8 @@ func (s *SmtpWriter) WriteMsg(msg string, level int) error {
...
@@ -64,12 +76,8 @@ func (s *SmtpWriter) WriteMsg(msg string, level int) error {
hp
:=
strings
.
Split
(
s
.
Host
,
":"
)
hp
:=
strings
.
Split
(
s
.
Host
,
":"
)
// Set up authentication information.
// Set up authentication information.
auth
:=
smtp
.
PlainAuth
(
auth
:=
s
.
GetSmtpAuth
(
hp
[
0
])
""
,
s
.
Username
,
s
.
Password
,
hp
[
0
],
)
// Connect to the server, authenticate, set the sender and recipient,
// Connect to the server, authenticate, set the sender and recipient,
// and send the email all in one step.
// and send the email all in one step.
content_type
:=
"Content-Type: text/plain"
+
"; charset=UTF-8"
content_type
:=
"Content-Type: text/plain"
+
"; charset=UTF-8"
...
...
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