mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-04 05:18:25 +00:00 
			
		
		
		
	user gomail and new activate account email tpl
- #1496: fallback plain text - #1002: add date header - #913: fix encoding of header
This commit is contained in:
		@@ -33,6 +33,7 @@ github.com/russross/blackfriday = commit:8cec3a854e
 | 
				
			|||||||
github.com/shurcooL/sanitized_anchor_name = commit:244f5ac324
 | 
					github.com/shurcooL/sanitized_anchor_name = commit:244f5ac324
 | 
				
			||||||
golang.org/x/net = 
 | 
					golang.org/x/net = 
 | 
				
			||||||
golang.org/x/text = 
 | 
					golang.org/x/text = 
 | 
				
			||||||
 | 
					gopkg.in/gomail.v2 = 
 | 
				
			||||||
gopkg.in/ini.v1 = commit:463307112d
 | 
					gopkg.in/ini.v1 = commit:463307112d
 | 
				
			||||||
gopkg.in/redis.v2 = commit:e617904962
 | 
					gopkg.in/redis.v2 = commit:e617904962
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -160,6 +160,11 @@ invalid_code = Sorry, your confirmation code has expired or not valid.
 | 
				
			|||||||
reset_password_helper = Click here to reset your password
 | 
					reset_password_helper = Click here to reset your password
 | 
				
			||||||
password_too_short = Password length cannot be less then 6.
 | 
					password_too_short = Password length cannot be less then 6.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[mail]
 | 
				
			||||||
 | 
					register_success = Register success, Welcome
 | 
				
			||||||
 | 
					activate_account = Please activate your account
 | 
				
			||||||
 | 
					activate_email = Verify your e-mail address
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[modal]
 | 
					[modal]
 | 
				
			||||||
yes = Yes
 | 
					yes = Yes
 | 
				
			||||||
no = No
 | 
					no = No
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -133,6 +133,22 @@ func (u *User) HomeLink() string {
 | 
				
			|||||||
	return setting.AppSubUrl + "/" + u.Name
 | 
						return setting.AppSubUrl + "/" + u.Name
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// GenerateEmailActivateCode generates an activate code based on user information and given e-mail.
 | 
				
			||||||
 | 
					func (u *User) GenerateEmailActivateCode(email string) string {
 | 
				
			||||||
 | 
						code := base.CreateTimeLimitCode(
 | 
				
			||||||
 | 
							com.ToStr(u.Id)+email+u.LowerName+u.Passwd+u.Rands,
 | 
				
			||||||
 | 
							setting.Service.ActiveCodeLives, nil)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Add tail hex username
 | 
				
			||||||
 | 
						code += hex.EncodeToString([]byte(u.LowerName))
 | 
				
			||||||
 | 
						return code
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// GenerateActivateCode generates an activate code based on user information.
 | 
				
			||||||
 | 
					func (u *User) GenerateActivateCode() string {
 | 
				
			||||||
 | 
						return u.GenerateEmailActivateCode(u.Email)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// CustomAvatarPath returns user custom avatar file path.
 | 
					// CustomAvatarPath returns user custom avatar file path.
 | 
				
			||||||
func (u *User) CustomAvatarPath() string {
 | 
					func (u *User) CustomAvatarPath() string {
 | 
				
			||||||
	return filepath.Join(setting.AvatarUploadPath, com.ToStr(u.Id))
 | 
						return filepath.Join(setting.AvatarUploadPath, com.ToStr(u.Id))
 | 
				
			||||||
 
 | 
				
			|||||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@@ -5,12 +5,10 @@
 | 
				
			|||||||
package mailer
 | 
					package mailer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"encoding/hex"
 | 
					 | 
				
			||||||
	"errors"
 | 
						"errors"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"path"
 | 
						"path"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/Unknwon/com"
 | 
					 | 
				
			||||||
	"github.com/Unknwon/macaron"
 | 
						"github.com/Unknwon/macaron"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/gogits/gogs/models"
 | 
						"github.com/gogits/gogs/models"
 | 
				
			||||||
@@ -20,26 +18,16 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
	AUTH_ACTIVE           base.TplName = "mail/auth/active"
 | 
					 | 
				
			||||||
	AUTH_ACTIVATE_EMAIL   base.TplName = "mail/auth/activate_email"
 | 
					 | 
				
			||||||
	AUTH_REGISTER_SUCCESS base.TplName = "mail/auth/register_success"
 | 
						AUTH_REGISTER_SUCCESS base.TplName = "mail/auth/register_success"
 | 
				
			||||||
 | 
						AUTH_ACTIVATE         base.TplName = "mail/auth/activate"
 | 
				
			||||||
 | 
						AUTH_ACTIVATE_EMAIL   base.TplName = "mail/auth/activate_email"
 | 
				
			||||||
	AUTH_RESET_PASSWORD   base.TplName = "mail/auth/reset_passwd"
 | 
						AUTH_RESET_PASSWORD   base.TplName = "mail/auth/reset_passwd"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	NOTIFY_COLLABORATOR base.TplName = "mail/notify/collaborator"
 | 
						NOTIFY_COLLABORATOR base.TplName = "mail/notify/collaborator"
 | 
				
			||||||
	NOTIFY_MENTION      base.TplName = "mail/notify/mention"
 | 
						NOTIFY_MENTION      base.TplName = "mail/notify/mention"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Create New mail message use MailFrom and MailUser
 | 
					func ComposeTplData(u *models.User) map[interface{}]interface{} {
 | 
				
			||||||
func NewMailMessageFrom(To []string, from, subject, body string) Message {
 | 
					 | 
				
			||||||
	return NewHtmlMessage(To, from, subject, body)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Create New mail message use MailFrom and MailUser
 | 
					 | 
				
			||||||
func NewMailMessage(To []string, subject, body string) Message {
 | 
					 | 
				
			||||||
	return NewMailMessageFrom(To, setting.MailService.From, subject, body)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func GetMailTmplData(u *models.User) map[interface{}]interface{} {
 | 
					 | 
				
			||||||
	data := make(map[interface{}]interface{}, 10)
 | 
						data := make(map[interface{}]interface{}, 10)
 | 
				
			||||||
	data["AppName"] = setting.AppName
 | 
						data["AppName"] = setting.AppName
 | 
				
			||||||
	data["AppVer"] = setting.AppVer
 | 
						data["AppVer"] = setting.AppVer
 | 
				
			||||||
@@ -52,95 +40,45 @@ func GetMailTmplData(u *models.User) map[interface{}]interface{} {
 | 
				
			|||||||
	return data
 | 
						return data
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// create a time limit code for user active
 | 
					func SendActivateAccountMail(c *macaron.Context, u *models.User) {
 | 
				
			||||||
func CreateUserActiveCode(u *models.User, startInf interface{}) string {
 | 
						data := ComposeTplData(u)
 | 
				
			||||||
	minutes := setting.Service.ActiveCodeLives
 | 
						data["Code"] = u.GenerateActivateCode()
 | 
				
			||||||
	data := com.ToStr(u.Id) + u.Email + u.LowerName + u.Passwd + u.Rands
 | 
						body, err := c.HTMLString(string(AUTH_ACTIVATE), data)
 | 
				
			||||||
	code := base.CreateTimeLimitCode(data, minutes, startInf)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// add tail hex username
 | 
					 | 
				
			||||||
	code += hex.EncodeToString([]byte(u.LowerName))
 | 
					 | 
				
			||||||
	return code
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// create a time limit code for user active
 | 
					 | 
				
			||||||
func CreateUserEmailActivateCode(u *models.User, e *models.EmailAddress, startInf interface{}) string {
 | 
					 | 
				
			||||||
	minutes := setting.Service.ActiveCodeLives
 | 
					 | 
				
			||||||
	data := com.ToStr(u.Id) + e.Email + u.LowerName + u.Passwd + u.Rands
 | 
					 | 
				
			||||||
	code := base.CreateTimeLimitCode(data, minutes, startInf)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// add tail hex username
 | 
					 | 
				
			||||||
	code += hex.EncodeToString([]byte(u.LowerName))
 | 
					 | 
				
			||||||
	return code
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Send user register mail with active code
 | 
					 | 
				
			||||||
func SendRegisterMail(r macaron.Render, u *models.User) {
 | 
					 | 
				
			||||||
	code := CreateUserActiveCode(u, nil)
 | 
					 | 
				
			||||||
	subject := "Register success, Welcome"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	data := GetMailTmplData(u)
 | 
					 | 
				
			||||||
	data["Code"] = code
 | 
					 | 
				
			||||||
	body, err := r.HTMLString(string(AUTH_REGISTER_SUCCESS), data)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		log.Error(4, "mail.SendRegisterMail(fail to render): %v", err)
 | 
							log.Error(4, "HTMLString: %v", err)
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	msg := NewMailMessage([]string{u.Email}, subject, body)
 | 
						msg := NewMessage([]string{u.Email}, c.Tr("mail.activate_account"), body)
 | 
				
			||||||
	msg.Info = fmt.Sprintf("UID: %d, send register mail", u.Id)
 | 
						msg.Info = fmt.Sprintf("UID: %d, activate account", u.Id)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	SendAsync(&msg)
 | 
						SendAsync(msg)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Send email verify active email.
 | 
					// SendActivateAccountMail sends confirmation e-mail.
 | 
				
			||||||
func SendActiveMail(r macaron.Render, u *models.User) {
 | 
					func SendActivateEmailMail(c *macaron.Context, u *models.User, email *models.EmailAddress) {
 | 
				
			||||||
	code := CreateUserActiveCode(u, nil)
 | 
						data := ComposeTplData(u)
 | 
				
			||||||
 | 
						data["Code"] = u.GenerateEmailActivateCode(email.Email)
 | 
				
			||||||
	subject := "Verify your e-mail address"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	data := GetMailTmplData(u)
 | 
					 | 
				
			||||||
	data["Code"] = code
 | 
					 | 
				
			||||||
	body, err := r.HTMLString(string(AUTH_ACTIVE), data)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		log.Error(4, "mail.SendActiveMail(fail to render): %v", err)
 | 
					 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	msg := NewMailMessage([]string{u.Email}, subject, body)
 | 
					 | 
				
			||||||
	msg.Info = fmt.Sprintf("UID: %d, send active mail", u.Id)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	SendAsync(&msg)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Send email to verify secondary email.
 | 
					 | 
				
			||||||
func SendActivateEmail(r macaron.Render, user *models.User, email *models.EmailAddress) {
 | 
					 | 
				
			||||||
	code := CreateUserEmailActivateCode(user, email, nil)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	subject := "Verify your e-mail address"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	data := GetMailTmplData(user)
 | 
					 | 
				
			||||||
	data["Code"] = code
 | 
					 | 
				
			||||||
	data["Email"] = email.Email
 | 
						data["Email"] = email.Email
 | 
				
			||||||
	body, err := r.HTMLString(string(AUTH_ACTIVATE_EMAIL), data)
 | 
						body, err := c.HTMLString(string(AUTH_ACTIVATE_EMAIL), data)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		log.Error(4, "mail.SendActiveMail(fail to render): %v", err)
 | 
							log.Error(4, "HTMLString: %v", err)
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	msg := NewMailMessage([]string{email.Email}, subject, body)
 | 
						msg := NewMessage([]string{email.Email}, c.Tr("mail.activate_email"), body)
 | 
				
			||||||
	msg.Info = fmt.Sprintf("UID: %d, send activate email to %s", user.Id, email.Email)
 | 
						msg.Info = fmt.Sprintf("UID: %d, activate email: %s", u.Id, email.Email)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	SendAsync(&msg)
 | 
						SendAsync(msg)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Send reset password email.
 | 
					// Send reset password email.
 | 
				
			||||||
func SendResetPasswdMail(r macaron.Render, u *models.User) {
 | 
					func SendResetPasswdMail(r macaron.Render, u *models.User) {
 | 
				
			||||||
	code := CreateUserActiveCode(u, nil)
 | 
						code := u.GenerateActivateCode()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	subject := "Reset your password"
 | 
						subject := "Reset your password"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	data := GetMailTmplData(u)
 | 
						data := ComposeTplData(u)
 | 
				
			||||||
	data["Code"] = code
 | 
						data["Code"] = code
 | 
				
			||||||
	body, err := r.HTMLString(string(AUTH_RESET_PASSWORD), data)
 | 
						body, err := r.HTMLString(string(AUTH_RESET_PASSWORD), data)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
@@ -148,10 +86,10 @@ func SendResetPasswdMail(r macaron.Render, u *models.User) {
 | 
				
			|||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	msg := NewMailMessage([]string{u.Email}, subject, body)
 | 
						msg := NewMessage([]string{u.Email}, subject, body)
 | 
				
			||||||
	msg.Info = fmt.Sprintf("UID: %d, send reset password email", u.Id)
 | 
						msg.Info = fmt.Sprintf("UID: %d, send reset password email", u.Id)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	SendAsync(&msg)
 | 
						SendAsync(msg)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// SendIssueNotifyMail sends mail notification of all watchers of repository.
 | 
					// SendIssueNotifyMail sends mail notification of all watchers of repository.
 | 
				
			||||||
@@ -182,9 +120,9 @@ func SendIssueNotifyMail(u, owner *models.User, repo *models.Repository, issue *
 | 
				
			|||||||
	content := fmt.Sprintf("%s<br>-<br> <a href=\"%s%s/%s/issues/%d\">View it on Gogs</a>.",
 | 
						content := fmt.Sprintf("%s<br>-<br> <a href=\"%s%s/%s/issues/%d\">View it on Gogs</a>.",
 | 
				
			||||||
		base.RenderSpecialLink([]byte(issue.Content), owner.Name+"/"+repo.Name),
 | 
							base.RenderSpecialLink([]byte(issue.Content), owner.Name+"/"+repo.Name),
 | 
				
			||||||
		setting.AppUrl, owner.Name, repo.Name, issue.Index)
 | 
							setting.AppUrl, owner.Name, repo.Name, issue.Index)
 | 
				
			||||||
	msg := NewMailMessageFrom(tos, u.Email, subject, content)
 | 
						msg := NewMessageFrom(tos, u.Email, subject, content)
 | 
				
			||||||
	msg.Info = fmt.Sprintf("Subject: %s, send issue notify emails", subject)
 | 
						msg.Info = fmt.Sprintf("Subject: %s, send issue notify emails", subject)
 | 
				
			||||||
	SendAsync(&msg)
 | 
						SendAsync(msg)
 | 
				
			||||||
	return tos, nil
 | 
						return tos, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -198,7 +136,7 @@ func SendIssueMentionMail(r macaron.Render, u, owner *models.User,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	subject := fmt.Sprintf("[%s] %s (#%d)", repo.Name, issue.Name, issue.Index)
 | 
						subject := fmt.Sprintf("[%s] %s (#%d)", repo.Name, issue.Name, issue.Index)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	data := GetMailTmplData(nil)
 | 
						data := ComposeTplData(nil)
 | 
				
			||||||
	data["IssueLink"] = fmt.Sprintf("%s/%s/issues/%d", owner.Name, repo.Name, issue.Index)
 | 
						data["IssueLink"] = fmt.Sprintf("%s/%s/issues/%d", owner.Name, repo.Name, issue.Index)
 | 
				
			||||||
	data["Subject"] = subject
 | 
						data["Subject"] = subject
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -207,9 +145,9 @@ func SendIssueMentionMail(r macaron.Render, u, owner *models.User,
 | 
				
			|||||||
		return fmt.Errorf("mail.SendIssueMentionMail(fail to render): %v", err)
 | 
							return fmt.Errorf("mail.SendIssueMentionMail(fail to render): %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	msg := NewMailMessageFrom(tos, u.Email, subject, body)
 | 
						msg := NewMessageFrom(tos, u.Email, subject, body)
 | 
				
			||||||
	msg.Info = fmt.Sprintf("Subject: %s, send issue mention emails", subject)
 | 
						msg.Info = fmt.Sprintf("Subject: %s, send issue mention emails", subject)
 | 
				
			||||||
	SendAsync(&msg)
 | 
						SendAsync(msg)
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -219,7 +157,7 @@ func SendCollaboratorMail(r macaron.Render, u, owner *models.User,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	subject := fmt.Sprintf("%s added you to %s", owner.Name, repo.Name)
 | 
						subject := fmt.Sprintf("%s added you to %s", owner.Name, repo.Name)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	data := GetMailTmplData(nil)
 | 
						data := ComposeTplData(nil)
 | 
				
			||||||
	data["RepoLink"] = path.Join(owner.Name, repo.Name)
 | 
						data["RepoLink"] = path.Join(owner.Name, repo.Name)
 | 
				
			||||||
	data["Subject"] = subject
 | 
						data["Subject"] = subject
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -228,9 +166,9 @@ func SendCollaboratorMail(r macaron.Render, u, owner *models.User,
 | 
				
			|||||||
		return fmt.Errorf("mail.SendCollaboratorMail(fail to render): %v", err)
 | 
							return fmt.Errorf("mail.SendCollaboratorMail(fail to render): %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	msg := NewMailMessage([]string{u.Email}, subject, body)
 | 
						msg := NewMessage([]string{u.Email}, subject, body)
 | 
				
			||||||
	msg.Info = fmt.Sprintf("UID: %d, send register mail", u.Id)
 | 
						msg.Info = fmt.Sprintf("UID: %d, send register mail", u.Id)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	SendAsync(&msg)
 | 
						SendAsync(msg)
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,16 +7,44 @@ package mailer
 | 
				
			|||||||
import (
 | 
					import (
 | 
				
			||||||
	"crypto/tls"
 | 
						"crypto/tls"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
 | 
						"io"
 | 
				
			||||||
	"net"
 | 
						"net"
 | 
				
			||||||
	"net/mail"
 | 
					 | 
				
			||||||
	"net/smtp"
 | 
						"net/smtp"
 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"gopkg.in/gomail.v2"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/gogits/gogs/modules/log"
 | 
						"github.com/gogits/gogs/modules/log"
 | 
				
			||||||
	"github.com/gogits/gogs/modules/setting"
 | 
						"github.com/gogits/gogs/modules/setting"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type Message struct {
 | 
				
			||||||
 | 
						Info string // Message information for log purpose.
 | 
				
			||||||
 | 
						*gomail.Message
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// NewMessageFrom creates new mail message object with custom From header.
 | 
				
			||||||
 | 
					func NewMessageFrom(to []string, from, subject, body string) *Message {
 | 
				
			||||||
 | 
						msg := gomail.NewMessage()
 | 
				
			||||||
 | 
						msg.SetHeader("From", from)
 | 
				
			||||||
 | 
						msg.SetHeader("To", to...)
 | 
				
			||||||
 | 
						msg.SetHeader("Subject", subject)
 | 
				
			||||||
 | 
						msg.SetDateHeader("Date", time.Now())
 | 
				
			||||||
 | 
						msg.SetBody("text/plain", body)
 | 
				
			||||||
 | 
						msg.AddAlternative("text/html", body)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return &Message{
 | 
				
			||||||
 | 
							Message: msg,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// NewMessage creates new mail message object with default From header.
 | 
				
			||||||
 | 
					func NewMessage(to []string, subject, body string) *Message {
 | 
				
			||||||
 | 
						return NewMessageFrom(to, setting.MailService.From, subject, body)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type loginAuth struct {
 | 
					type loginAuth struct {
 | 
				
			||||||
	username, password string
 | 
						username, password string
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -44,74 +72,24 @@ func (a *loginAuth) Next(fromServer []byte, more bool) ([]byte, error) {
 | 
				
			|||||||
	return nil, nil
 | 
						return nil, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Message struct {
 | 
					type Sender struct {
 | 
				
			||||||
	To      []string
 | 
					 | 
				
			||||||
	From    string
 | 
					 | 
				
			||||||
	Subject string
 | 
					 | 
				
			||||||
	ReplyTo string
 | 
					 | 
				
			||||||
	Body    string
 | 
					 | 
				
			||||||
	Type    string
 | 
					 | 
				
			||||||
	Massive bool
 | 
					 | 
				
			||||||
	Info    string
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// create mail content
 | 
					func (s *Sender) Send(from string, to []string, msg io.WriterTo) error {
 | 
				
			||||||
func (m Message) Content() string {
 | 
						opts := setting.MailService
 | 
				
			||||||
	// set mail type
 | 
					 | 
				
			||||||
	contentType := "text/plain; charset=UTF-8"
 | 
					 | 
				
			||||||
	if m.Type == "html" {
 | 
					 | 
				
			||||||
		contentType = "text/html; charset=UTF-8"
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// create mail content
 | 
						host, port, err := net.SplitHostPort(opts.Host)
 | 
				
			||||||
	content := "From: " + m.From + "\r\nReply-To: " + m.ReplyTo + "\r\nSubject: " + m.Subject + "\r\nContent-Type: " + contentType + "\r\n\r\n" + m.Body
 | 
					 | 
				
			||||||
	return content
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
var mailQueue chan *Message
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func NewContext() {
 | 
					 | 
				
			||||||
	if setting.MailService == nil {
 | 
					 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	mailQueue = make(chan *Message, setting.MailService.QueueLength)
 | 
					 | 
				
			||||||
	go processMailQueue()
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func processMailQueue() {
 | 
					 | 
				
			||||||
	for {
 | 
					 | 
				
			||||||
		select {
 | 
					 | 
				
			||||||
		case msg := <-mailQueue:
 | 
					 | 
				
			||||||
			num, err := Send(msg)
 | 
					 | 
				
			||||||
			tos := strings.Join(msg.To, ", ")
 | 
					 | 
				
			||||||
			info := ""
 | 
					 | 
				
			||||||
			if err != nil {
 | 
					 | 
				
			||||||
				if len(msg.Info) > 0 {
 | 
					 | 
				
			||||||
					info = ", info: " + msg.Info
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
				log.Error(4, fmt.Sprintf("Async sent email %d succeed, not send emails: %s%s err: %s", num, tos, info, err))
 | 
					 | 
				
			||||||
			} else {
 | 
					 | 
				
			||||||
				log.Trace(fmt.Sprintf("Async sent email %d succeed, sent emails: %s%s", num, tos, info))
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// sendMail allows mail with self-signed certificates.
 | 
					 | 
				
			||||||
func sendMail(settings *setting.Mailer, recipients []string, msgContent []byte) error {
 | 
					 | 
				
			||||||
	host, port, err := net.SplitHostPort(settings.Host)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tlsconfig := &tls.Config{
 | 
						tlsconfig := &tls.Config{
 | 
				
			||||||
		InsecureSkipVerify: settings.SkipVerify,
 | 
							InsecureSkipVerify: opts.SkipVerify,
 | 
				
			||||||
		ServerName:         host,
 | 
							ServerName:         host,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if settings.UseCertificate {
 | 
						if opts.UseCertificate {
 | 
				
			||||||
		cert, err := tls.LoadX509KeyPair(settings.CertFile, settings.KeyFile)
 | 
							cert, err := tls.LoadX509KeyPair(opts.CertFile, opts.KeyFile)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return err
 | 
								return err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -159,17 +137,16 @@ func sendMail(settings *setting.Mailer, recipients []string, msgContent []byte)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	canAuth, options := client.Extension("AUTH")
 | 
						canAuth, options := client.Extension("AUTH")
 | 
				
			||||||
 | 
						if canAuth && len(opts.User) > 0 {
 | 
				
			||||||
	if canAuth && len(settings.User) > 0 {
 | 
					 | 
				
			||||||
		var auth smtp.Auth
 | 
							var auth smtp.Auth
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if strings.Contains(options, "CRAM-MD5") {
 | 
							if strings.Contains(options, "CRAM-MD5") {
 | 
				
			||||||
			auth = smtp.CRAMMD5Auth(settings.User, settings.Passwd)
 | 
								auth = smtp.CRAMMD5Auth(opts.User, opts.Passwd)
 | 
				
			||||||
		} else if strings.Contains(options, "PLAIN") {
 | 
							} else if strings.Contains(options, "PLAIN") {
 | 
				
			||||||
			auth = smtp.PlainAuth("", settings.User, settings.Passwd, host)
 | 
								auth = smtp.PlainAuth("", opts.User, opts.Passwd, host)
 | 
				
			||||||
		} else if strings.Contains(options, "LOGIN") {
 | 
							} else if strings.Contains(options, "LOGIN") {
 | 
				
			||||||
			// Patch for AUTH LOGIN
 | 
								// Patch for AUTH LOGIN
 | 
				
			||||||
			auth = LoginAuth(settings.User, settings.Passwd)
 | 
								auth = LoginAuth(opts.User, opts.Passwd)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if auth != nil {
 | 
							if auth != nil {
 | 
				
			||||||
@@ -179,15 +156,11 @@ func sendMail(settings *setting.Mailer, recipients []string, msgContent []byte)
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if fromAddress, err := mail.ParseAddress(settings.From); err != nil {
 | 
						if err = client.Mail(from); err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		if err = client.Mail(fromAddress.Address); err != nil {
 | 
					 | 
				
			||||||
			return err
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for _, rec := range recipients {
 | 
						for _, rec := range to {
 | 
				
			||||||
		if err = client.Rcpt(rec); err != nil {
 | 
							if err = client.Rcpt(rec); err != nil {
 | 
				
			||||||
			return err
 | 
								return err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -196,71 +169,44 @@ func sendMail(settings *setting.Mailer, recipients []string, msgContent []byte)
 | 
				
			|||||||
	w, err := client.Data()
 | 
						w, err := client.Data()
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						} else if _, err = msg.WriteTo(w); err != nil {
 | 
				
			||||||
	if _, err = w.Write([]byte(msgContent)); err != nil {
 | 
					 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						} else if err = w.Close(); err != nil {
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if err = w.Close(); err != nil {
 | 
					 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return client.Quit()
 | 
						return client.Quit()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Direct Send mail message
 | 
					func processMailQueue() {
 | 
				
			||||||
func Send(msg *Message) (int, error) {
 | 
						sender := &Sender{}
 | 
				
			||||||
	log.Trace("Sending mails to: %s", strings.Join(msg.To, ", "))
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// get message body
 | 
						for {
 | 
				
			||||||
	content := msg.Content()
 | 
							select {
 | 
				
			||||||
 | 
							case msg := <-mailQueue:
 | 
				
			||||||
	if len(msg.To) == 0 {
 | 
								log.Trace("New e-mail sending request %s: %s", msg.GetHeader("To"), msg.Info)
 | 
				
			||||||
		return 0, fmt.Errorf("empty receive emails")
 | 
								if err := gomail.Send(sender, msg.Message); err != nil {
 | 
				
			||||||
	} else if len(msg.Body) == 0 {
 | 
									log.Error(4, "Fail to send e-mails %s: %s - %v", msg.GetHeader("To"), msg.Info, err)
 | 
				
			||||||
		return 0, fmt.Errorf("empty email body")
 | 
								} else {
 | 
				
			||||||
	}
 | 
									log.Trace("E-mails sent %s: %s", msg.GetHeader("To"), msg.Info)
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if msg.Massive {
 | 
					 | 
				
			||||||
		// send mail to multiple emails one by one
 | 
					 | 
				
			||||||
		num := 0
 | 
					 | 
				
			||||||
		for _, to := range msg.To {
 | 
					 | 
				
			||||||
			body := []byte("To: " + to + "\r\n" + content)
 | 
					 | 
				
			||||||
			err := sendMail(setting.MailService, []string{to}, body)
 | 
					 | 
				
			||||||
			if err != nil {
 | 
					 | 
				
			||||||
				return num, err
 | 
					 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			num++
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		return num, nil
 | 
					 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		body := []byte("To: " + strings.Join(msg.To, ",") + "\r\n" + content)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		// send to multiple emails in one message
 | 
					 | 
				
			||||||
		err := sendMail(setting.MailService, msg.To, body)
 | 
					 | 
				
			||||||
		if err != nil {
 | 
					 | 
				
			||||||
			return 0, err
 | 
					 | 
				
			||||||
		} else {
 | 
					 | 
				
			||||||
			return 1, nil
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Async Send mail message
 | 
					var mailQueue chan *Message
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func NewContext() {
 | 
				
			||||||
 | 
						if setting.MailService == nil {
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						mailQueue = make(chan *Message, setting.MailService.QueueLength)
 | 
				
			||||||
 | 
						go processMailQueue()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func SendAsync(msg *Message) {
 | 
					func SendAsync(msg *Message) {
 | 
				
			||||||
	go func() {
 | 
						go func() {
 | 
				
			||||||
		mailQueue <- msg
 | 
							mailQueue <- msg
 | 
				
			||||||
	}()
 | 
						}()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
// Create html mail message
 | 
					 | 
				
			||||||
func NewHtmlMessage(To []string, From, Subject, Body string) Message {
 | 
					 | 
				
			||||||
	return Message{
 | 
					 | 
				
			||||||
		To:      To,
 | 
					 | 
				
			||||||
		From:    setting.MailService.From,
 | 
					 | 
				
			||||||
		ReplyTo: From,
 | 
					 | 
				
			||||||
		Subject: Subject,
 | 
					 | 
				
			||||||
		Body:    Body,
 | 
					 | 
				
			||||||
		Type:    "html",
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								public/css/gogs.min.css
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								public/css/gogs.min.css
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@@ -46,6 +46,7 @@
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.user.activate,
 | 
				
			||||||
.signin,
 | 
					.signin,
 | 
				
			||||||
.signup {
 | 
					.signup {
 | 
				
			||||||
	@input-padding: 200px!important;
 | 
						@input-padding: 200px!important;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,5 +20,6 @@ func TemplatePreview(ctx *middleware.Context) {
 | 
				
			|||||||
	ctx.Data["ActiveCodeLives"] = setting.Service.ActiveCodeLives / 60
 | 
						ctx.Data["ActiveCodeLives"] = setting.Service.ActiveCodeLives / 60
 | 
				
			||||||
	ctx.Data["ResetPwdCodeLives"] = setting.Service.ResetPwdCodeLives / 60
 | 
						ctx.Data["ResetPwdCodeLives"] = setting.Service.ResetPwdCodeLives / 60
 | 
				
			||||||
	ctx.Data["CurDbValue"] = ""
 | 
						ctx.Data["CurDbValue"] = ""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctx.HTML(200, base.TplName(ctx.Params("*")))
 | 
						ctx.HTML(200, base.TplName(ctx.Params("*")))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -45,6 +45,7 @@ func checkRunMode() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func NewServices() {
 | 
					func NewServices() {
 | 
				
			||||||
	setting.NewServices()
 | 
						setting.NewServices()
 | 
				
			||||||
 | 
						mailer.NewContext()
 | 
				
			||||||
	social.NewOauthService()
 | 
						social.NewOauthService()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -53,7 +54,6 @@ func GlobalInit() {
 | 
				
			|||||||
	setting.NewContext()
 | 
						setting.NewContext()
 | 
				
			||||||
	log.Trace("Custom path: %s", setting.CustomPath)
 | 
						log.Trace("Custom path: %s", setting.CustomPath)
 | 
				
			||||||
	log.Trace("Log path: %s", setting.LogRootPath)
 | 
						log.Trace("Log path: %s", setting.LogRootPath)
 | 
				
			||||||
	mailer.NewContext()
 | 
					 | 
				
			||||||
	models.LoadConfigs()
 | 
						models.LoadConfigs()
 | 
				
			||||||
	NewServices()
 | 
						NewServices()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -249,7 +249,7 @@ func SignUpPost(ctx *middleware.Context, cpt *captcha.Captcha, form auth.Registe
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// Send confirmation e-mail, no need for social account.
 | 
						// Send confirmation e-mail, no need for social account.
 | 
				
			||||||
	if !isOauth && setting.Service.RegisterEmailConfirm && u.Id > 1 {
 | 
						if !isOauth && setting.Service.RegisterEmailConfirm && u.Id > 1 {
 | 
				
			||||||
		mailer.SendRegisterMail(ctx.Render, u)
 | 
							mailer.SendActivateAccountMail(ctx.Context, u)
 | 
				
			||||||
		ctx.Data["IsSendRegisterMail"] = true
 | 
							ctx.Data["IsSendRegisterMail"] = true
 | 
				
			||||||
		ctx.Data["Email"] = u.Email
 | 
							ctx.Data["Email"] = u.Email
 | 
				
			||||||
		ctx.Data["Hours"] = setting.Service.ActiveCodeLives / 60
 | 
							ctx.Data["Hours"] = setting.Service.ActiveCodeLives / 60
 | 
				
			||||||
@@ -278,7 +278,7 @@ func Activate(ctx *middleware.Context) {
 | 
				
			|||||||
				ctx.Data["ResendLimited"] = true
 | 
									ctx.Data["ResendLimited"] = true
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				ctx.Data["Hours"] = setting.Service.ActiveCodeLives / 60
 | 
									ctx.Data["Hours"] = setting.Service.ActiveCodeLives / 60
 | 
				
			||||||
				mailer.SendActiveMail(ctx.Render, ctx.User)
 | 
									mailer.SendActivateAccountMail(ctx.Context, ctx.User)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				if err := ctx.Cache.Put("MailResendLimit_"+ctx.User.LowerName, ctx.User.LowerName, 180); err != nil {
 | 
									if err := ctx.Cache.Put("MailResendLimit_"+ctx.User.LowerName, ctx.User.LowerName, 180); err != nil {
 | 
				
			||||||
					log.Error(4, "Set cache(MailResendLimit) fail: %v", err)
 | 
										log.Error(4, "Set cache(MailResendLimit) fail: %v", err)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -225,7 +225,7 @@ func SettingsEmailPost(ctx *middleware.Context, form auth.AddEmailForm) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// Send confirmation e-mail
 | 
						// Send confirmation e-mail
 | 
				
			||||||
	if setting.Service.RegisterEmailConfirm {
 | 
						if setting.Service.RegisterEmailConfirm {
 | 
				
			||||||
		mailer.SendActivateEmail(ctx.Render, ctx.User, e)
 | 
							mailer.SendActivateEmailMail(ctx.Context, ctx.User, e)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if err := ctx.Cache.Put("MailResendLimit_"+ctx.User.LowerName, ctx.User.LowerName, 180); err != nil {
 | 
							if err := ctx.Cache.Put("MailResendLimit_"+ctx.User.LowerName, ctx.User.LowerName, 180); err != nil {
 | 
				
			||||||
			log.Error(4, "Set cache(MailResendLimit) fail: %v", err)
 | 
								log.Error(4, "Set cache(MailResendLimit) fail: %v", err)
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										15
									
								
								templates/mail/auth/activate.tmpl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								templates/mail/auth/activate.tmpl
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
				
			|||||||
 | 
					<!DOCTYPE html>
 | 
				
			||||||
 | 
					<html>  
 | 
				
			||||||
 | 
					<head>
 | 
				
			||||||
 | 
					  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 | 
				
			||||||
 | 
					  <title>{{.User.Name}}, please activate your account</title>
 | 
				
			||||||
 | 
					</head>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<body>
 | 
				
			||||||
 | 
					  <p>Hi <b>{{.User.Name}}</b>, thanks for registering at {{.AppName}}!</p>
 | 
				
			||||||
 | 
					  <p>Please click the following link to verify your e-mail address within <b>{{.ActiveCodeLives}} hours</b>:</p>
 | 
				
			||||||
 | 
					  <p><a href="{{.AppUrl}}user/activate?code={{.Code}}">{{.AppUrl}}user/activate?code={{.Code}}</a></p>
 | 
				
			||||||
 | 
					  <p>Not working? Try copying and pasting it to your browser.</p>
 | 
				
			||||||
 | 
					  <p>© 2015 <a target="_blank" href="http://gogs.io">Gogs: Go Git Service</a></p>
 | 
				
			||||||
 | 
					</body>
 | 
				
			||||||
 | 
					</html>
 | 
				
			||||||
@@ -1,33 +0,0 @@
 | 
				
			|||||||
<!DOCTYPE html>
 | 
					 | 
				
			||||||
<html>
 | 
					 | 
				
			||||||
<head>
 | 
					 | 
				
			||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 | 
					 | 
				
			||||||
<title>{{.User.Name}}, please activate your account</title>
 | 
					 | 
				
			||||||
</head>
 | 
					 | 
				
			||||||
<body style="background:#eee;">
 | 
					 | 
				
			||||||
<div style="color:#333; font:12px/1.5 Tahoma,Arial,sans-serif;; text-shadow:1px 1px #fff; padding:0; margin:0;">
 | 
					 | 
				
			||||||
    <div style="width:600px;margin:0 auto; padding:40px 0 20px;">
 | 
					 | 
				
			||||||
        <div style="border:1px solid #d9d9d9;border-radius:3px; background:#fff; box-shadow: 0px 2px 5px rgba(0, 0, 0,.05); -webkit-box-shadow: 0px 2px 5px rgba(0, 0, 0,.05);">
 | 
					 | 
				
			||||||
            <div style="padding: 20px 15px;">
 | 
					 | 
				
			||||||
                <h1 style="font-size:20px; padding:10px 0 20px; margin:0; border-bottom:1px solid #ddd;"><img src="{{.AppUrl}}/img/favicon.png" style="height: 32px; margin-bottom: -10px;"> <a style="color:#333;text-decoration:none;" target="_blank" href="{{.AppUrl}}">{{.AppName}}</a></h1>
 | 
					 | 
				
			||||||
                <div style="padding:40px 15px;">
 | 
					 | 
				
			||||||
                    <div style="font-size:16px; padding-bottom:30px; font-weight:bold;">
 | 
					 | 
				
			||||||
                        Hi <span style="color: #00BFFF;">{{.User.Name}}</span>,
 | 
					 | 
				
			||||||
                    </div>
 | 
					 | 
				
			||||||
                    <div style="font-size:14px; padding:0 15px;">
 | 
					 | 
				
			||||||
						<p style="margin:0;padding:0 0 9px 0;">Please click the following link to verify your e-mail address within <b>{{.ActiveCodeLives}} hours</b>.</p>
 | 
					 | 
				
			||||||
						<p style="margin:0;padding:0 0 9px 0;">
 | 
					 | 
				
			||||||
							<a href="{{.AppUrl}}user/activate?code={{.Code}}">{{.AppUrl}}user/activate?code={{.Code}}</a>
 | 
					 | 
				
			||||||
						</p>
 | 
					 | 
				
			||||||
						<p style="margin:0;padding:0 0 9px 0;">Not working? Try copying and pasting it to your browser.</p>
 | 
					 | 
				
			||||||
                    </div>
 | 
					 | 
				
			||||||
                </div>
 | 
					 | 
				
			||||||
            </div>
 | 
					 | 
				
			||||||
        </div>
 | 
					 | 
				
			||||||
        <div style="color:#aaa;padding:10px;text-align:center;">
 | 
					 | 
				
			||||||
            © 2014 <a style="color:#888;text-decoration:none;" target="_blank" href="http://gogits.org">Gogs: Go Git Service</a>
 | 
					 | 
				
			||||||
        </div>
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
</div>
 | 
					 | 
				
			||||||
</body>
 | 
					 | 
				
			||||||
</html>
 | 
					 | 
				
			||||||
@@ -1,33 +1,22 @@
 | 
				
			|||||||
<!DOCTYPE html>
 | 
					<!DOCTYPE html>
 | 
				
			||||||
<html>
 | 
					<html>  
 | 
				
			||||||
<head>
 | 
					<head>
 | 
				
			||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 | 
					  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 | 
				
			||||||
<title>{{.User.Name}}, welcome to {{.AppName}}</title>
 | 
					  <title>{{.User.Name}}, welcome to {{.AppName}}</title>
 | 
				
			||||||
</head>
 | 
					</head>
 | 
				
			||||||
<body style="background:#eee;">
 | 
					
 | 
				
			||||||
<div style="color:#333; font:12px/1.5 Tahoma,Arial,sans-serif;; text-shadow:1px 1px #fff; padding:0; margin:0;">
 | 
					<body class="mail register success">
 | 
				
			||||||
    <div style="width:600px;margin:0 auto; padding:40px 0 20px;">
 | 
					  <div class="ui segment">
 | 
				
			||||||
        <div style="border:1px solid #d9d9d9;border-radius:3px; background:#fff; box-shadow: 0px 2px 5px rgba(0, 0, 0,.05); -webkit-box-shadow: 0px 2px 5px rgba(0, 0, 0,.05);">
 | 
					    <div class="ui header">
 | 
				
			||||||
            <div style="padding: 20px 15px;">
 | 
					      <img class="ui image" src="{{.AppUrl}}/img/favicon.png">
 | 
				
			||||||
                <h1 style="font-size:20px; padding:10px 0 20px; margin:0; border-bottom:1px solid #ddd;"><img src="{{.AppUrl}}/img/favicon.png" style="height: 32px; margin-bottom: -10px;"> <a style="color:#333;text-decoration:none;" target="_blank" href="{{.AppUrl}}">{{.AppName}}</a></h1>
 | 
					      {{.AppName}}
 | 
				
			||||||
                <div style="padding:40px 15px;">
 | 
					 | 
				
			||||||
                    <div style="font-size:16px; padding-bottom:30px; font-weight:bold;">
 | 
					 | 
				
			||||||
                        Hi <span style="color: #00BFFF;">{{.User.Name}}</span>, this is your registration email for {{.AppName}}!
 | 
					 | 
				
			||||||
                    </div>
 | 
					 | 
				
			||||||
                    <div style="font-size:14px; padding:0 15px;">
 | 
					 | 
				
			||||||
						<p style="margin:0;padding:0 0 9px 0;">Please click the following link to verify your e-mail address within <b>{{.ActiveCodeLives}} hours</b>.</p>
 | 
					 | 
				
			||||||
						<p style="margin:0;padding:0 0 9px 0;">
 | 
					 | 
				
			||||||
							<a href="{{.AppUrl}}user/activate?code={{.Code}}">{{.AppUrl}}user/activate?code={{.Code}}</a>
 | 
					 | 
				
			||||||
						</p>
 | 
					 | 
				
			||||||
						<p style="margin:0;padding:0 0 9px 0;">Not working? Try copying and pasting it to your browser.</p>
 | 
					 | 
				
			||||||
                    </div>
 | 
					 | 
				
			||||||
                </div>
 | 
					 | 
				
			||||||
            </div>
 | 
					 | 
				
			||||||
        </div>
 | 
					 | 
				
			||||||
        <div style="color:#aaa;padding:10px;text-align:center;">
 | 
					 | 
				
			||||||
            © 2014 <a style="color:#888;text-decoration:none;" target="_blank" href="http://gogits.org">Gogs: Go Git Service</a>
 | 
					 | 
				
			||||||
        </div>
 | 
					 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
</div>
 | 
					    <div class="ui divider"></div>
 | 
				
			||||||
 | 
					    <p>Hi <b>{{.User.Name}}</b>, this is your registration email for {{.AppName}}!</p>
 | 
				
			||||||
 | 
					    <p>Please click the following link to verify your e-mail address within <b>{{.ActiveCodeLives}} hours</b>:</p>
 | 
				
			||||||
 | 
					    <p><a href="{{.AppUrl}}user/activate?code={{.Code}}">{{.AppUrl}}user/activate?code={{.Code}}</a></p>
 | 
				
			||||||
 | 
					    <p>Not working? Try copying and pasting it to your browser.</p>
 | 
				
			||||||
 | 
					  </div>
 | 
				
			||||||
 | 
					  <p class="copyright text grey">© 2015 <a target="_blank" href="http://gogs.io">Gogs: Go Git Service</a></p>
 | 
				
			||||||
</body>
 | 
					</body>
 | 
				
			||||||
</html>
 | 
					</html>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,39 +1,45 @@
 | 
				
			|||||||
{{template "ng/base/head" .}}
 | 
					{{template "base/head" .}}
 | 
				
			||||||
{{template "ng/base/header" .}}
 | 
					<div class="user activate">
 | 
				
			||||||
<div id="sign-wrapper">
 | 
					  <div class="ui middle very relaxed page grid">
 | 
				
			||||||
    <form class="form-align form panel sign-panel sign-form container panel-radius" id="sign-up-form" action="{{AppSubUrl}}/user/activate" method="post">
 | 
					    <div class="column">
 | 
				
			||||||
 | 
					      <form class="ui form" action="{{AppSubUrl}}/user/activate" method="post">
 | 
				
			||||||
        {{.CsrfTokenHtml}}
 | 
					        {{.CsrfTokenHtml}}
 | 
				
			||||||
        <div class="panel-header">
 | 
					        <h2 class="ui top attached header">
 | 
				
			||||||
            <h2>{{.i18n.Tr "auth.active_your_account"}}</h2>
 | 
					          {{.i18n.Tr "auth.active_your_account"}}
 | 
				
			||||||
        </div>
 | 
					        </h2>
 | 
				
			||||||
        <div class="panel-content">
 | 
					        <div class="ui attached segment">
 | 
				
			||||||
        {{if .IsActivatePage}}
 | 
					          {{if .IsActivatePage}}
 | 
				
			||||||
            {{if .ServiceNotEnabled}}
 | 
					            {{if .ServiceNotEnabled}}
 | 
				
			||||||
            <p>{{.i18n.Tr "auth.disable_register_mail"}}</p>
 | 
					            <p>{{.i18n.Tr "auth.disable_register_mail"}}</p>
 | 
				
			||||||
            {{else if .ResendLimited}}
 | 
					            {{else if .ResendLimited}}
 | 
				
			||||||
            <p>{{.i18n.Tr "auth.resent_limit_prompt"}}</p>
 | 
					            <p>{{.i18n.Tr "auth.resent_limit_prompt"}}</p>
 | 
				
			||||||
            {{else}}
 | 
					            {{else}}
 | 
				
			||||||
            <p>{{.i18n.Tr "auth.confirmation_mail_sent_prompt" .SignedUser.Email .Hours | Str2html}}</p>
 | 
					            <p>{{.i18n.Tr "auth.confirmation_mail_sent_prompt" .SignedUser.Email .Hours | Str2html}}</p>
 | 
				
			||||||
            <hr/>
 | 
					            <div class="ui divider"></div>
 | 
				
			||||||
            <label></label>
 | 
					            <div class="text right">
 | 
				
			||||||
            <a class="btn btn-green btn-large btn-link btn-radius" href="http://{{Mail2Domain .SignedUser.Email}}">{{.i18n.Tr "auth.sign_in_email"}}</a>
 | 
					              <a class="ui green button" href="http://{{Mail2Domain .SignedUser.Email}}">{{.i18n.Tr "auth.sign_in_to_account"}}</a>
 | 
				
			||||||
 | 
					            </div>
 | 
				
			||||||
            {{end}}
 | 
					            {{end}}
 | 
				
			||||||
        {{else}}
 | 
					          {{else}}
 | 
				
			||||||
            {{if .IsSendRegisterMail}}
 | 
					            {{if .IsSendRegisterMail}}
 | 
				
			||||||
            <p>{{.i18n.Tr "auth.confirmation_mail_sent_prompt" .Email .Hours | Str2html}}</p>
 | 
					            <p>{{.i18n.Tr "auth.confirmation_mail_sent_prompt" .Email .Hours | Str2html}}</p>
 | 
				
			||||||
            <hr/>
 | 
					            <div class="ui divider"></div>
 | 
				
			||||||
            <label></label>
 | 
					            <div class="text right">
 | 
				
			||||||
            <a class="btn btn-green btn-large btn-link btn-radius" href="http://{{Mail2Domain .Email}}">{{.i18n.Tr "auth.sign_in_to_account"}}</a>
 | 
					              <a class="ui green button" href="http://{{Mail2Domain .Email}}">{{.i18n.Tr "auth.sign_in_to_account"}}</a>
 | 
				
			||||||
 | 
					            </div>
 | 
				
			||||||
            {{else if .IsActivateFailed}}
 | 
					            {{else if .IsActivateFailed}}
 | 
				
			||||||
            <p>{{.i18n.Tr "auth.invalid_code"}}</p>
 | 
					            <p>{{.i18n.Tr "auth.invalid_code"}}</p>
 | 
				
			||||||
            {{else}}
 | 
					            {{else}}
 | 
				
			||||||
            <p>{{.i18n.Tr "auth.has_unconfirmed_mail" .SignedUser.Name .SignedUser.Email | Str2html}}</p>
 | 
					            <p>{{.i18n.Tr "auth.has_unconfirmed_mail" .SignedUser.Name .SignedUser.Email | Str2html}}</p>
 | 
				
			||||||
            <hr/>
 | 
					            <div class="ui divider"></div>
 | 
				
			||||||
            <label></label>
 | 
					            <div class="text right">
 | 
				
			||||||
            <button class="btn btn-blue btn-large btn-radius">{{.i18n.Tr "auth.resend_mail"}}</button>
 | 
					              <button class="ui blue button" href="http://{{Mail2Domain .SignedUser.Email}}">{{.i18n.Tr "auth.resend_mail"}}</button>
 | 
				
			||||||
 | 
					            </div>
 | 
				
			||||||
            {{end}}
 | 
					            {{end}}
 | 
				
			||||||
        {{end}}
 | 
					          {{end}}
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
    </form>
 | 
					      </form>
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					  </div>  
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
{{template "ng/base/footer" .}}
 | 
					{{template "base/footer" .}}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user