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
770dc702
Commit
770dc702
authored
Aug 27, 2014
by
astaxie
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #782 from francoishill/patch-19
Extra field if username is empty
parents
e146100a
61ce6088
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
smtp.go
logs/smtp.go
+4
-2
No files found.
logs/smtp.go
View file @
770dc702
...
...
@@ -34,6 +34,7 @@ type SmtpWriter struct {
Password
string
`json:"password"`
Host
string
`json:"Host"`
Subject
string
`json:"subject"`
FromAddress
string
`json:"fromAddress"
RecipientAddresses []string `
json
:
"sendTos"`
Level int `
json
:
"level"`
}
...
...
@@ -50,6 +51,7 @@ func NewSmtpWriter() LoggerInterface {
// "password:"password",
// "host":"smtp.gmail.com:465",
// "subject":"email title",
// "fromAddress":"from@example.com",
// "sendTos":["email1","email2"],
// "level":LevelError
// }
...
...
@@ -141,10 +143,10 @@ func (s *SmtpWriter) WriteMsg(msg string, level int) error {
// Connect to the server, authenticate, set the sender and recipient,
// and send the email all in one step.
content_type := "Content-Type: text/plain" + "; charset=UTF-8"
mailmsg
:=
[]
byte
(
"To: "
+
strings
.
Join
(
s
.
RecipientAddresses
,
";"
)
+
"
\r\n
From: "
+
s
.
Username
+
"<"
+
s
.
Username
+
mailmsg := []byte("To: " + strings.Join(s.RecipientAddresses, ";") + "\r\nFrom: " + s.
FromAddress + "<" + s.FromAddress
+
">\r\nSubject: " + s.Subject + "\r\n" + content_type + "\r\n\r\n" + fmt.Sprintf(".%s", time.Now().Format("2006-01-02 15:04:05")) + msg)
err
:=
s
.
sendMail
(
s
.
Host
,
auth
,
s
.
Username
,
s
.
RecipientAddresses
,
mailmsg
)
err := s.sendMail(s.Host, auth, s.
FromAddress
, s.RecipientAddresses, mailmsg)
return err
}
...
...
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