2014-06-03 18:27:20 +00:00
|
|
|
package models
|
|
|
|
|
2015-02-07 20:31:41 +00:00
|
|
|
// SMTP contains the attributes needed to handle the sending of campaign emails
|
2014-06-03 18:27:20 +00:00
|
|
|
type SMTP struct {
|
2015-02-07 20:31:41 +00:00
|
|
|
SMTPId int64 `json:"-" gorm:"column:smtp_id; primary_key:yes"`
|
|
|
|
CampaignId int64 `json:"-" gorm:"column:campaign_id"`
|
2014-06-05 04:54:46 +00:00
|
|
|
Host string `json:"host"`
|
2014-06-03 18:27:20 +00:00
|
|
|
Username string `json:"username,omitempty"`
|
|
|
|
Password string `json:"password,omitempty" sql:"-"`
|
|
|
|
FromAddress string `json:"from_address"`
|
|
|
|
}
|
|
|
|
|
2015-02-07 20:31:41 +00:00
|
|
|
// TableName specifies the database tablename for Gorm to use
|
|
|
|
func (s SMTP) TableName() string {
|
|
|
|
return "smtp"
|
|
|
|
}
|
|
|
|
|
|
|
|
// Validate ensures that SMTP configs/connections are valid
|
2014-06-03 18:27:20 +00:00
|
|
|
func (s *SMTP) Validate() (string, bool) {
|
|
|
|
switch {
|
|
|
|
case s.FromAddress == "":
|
|
|
|
return "No from address specified", false
|
2014-06-05 04:54:46 +00:00
|
|
|
case s.Host == "":
|
2014-06-03 18:27:20 +00:00
|
|
|
return "No hostname specified", false
|
|
|
|
}
|
|
|
|
return "", true
|
|
|
|
}
|