Merge pull request #1155 from freesteph/fix/allow-eu-emails

email: allow sending emails from EU Mailgun domains
pull/1131/head
Matt Baer 6 days ago committed by GitHub
commit 0be229cdaa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      config/config.go
  2. 6
      email.go
  3. 3
      mailer/mailer.go

@ -181,6 +181,7 @@ type (
// Mailgun configuration values
Domain string `ini:"domain"`
MailgunPrivate string `ini:"mailgun_private"`
MailgunEurope bool `ini:"mailgun_europe"`
}
// Config holds the complete configuration for running a writefreely instance

@ -309,6 +309,12 @@ Originally published on ` + p.Collection.DisplayTitle() + ` (` + p.Collection.Ca
Sent to %recipient.to%. Unsubscribe: ` + p.Collection.CanonicalURL() + `email/unsubscribe/%recipient.id%?t=%recipient.token%`
gun := mailgun.NewMailgun(app.cfg.Email.Domain, app.cfg.Email.MailgunPrivate)
if app.cfg.Email.MailgunEurope {
gun.SetAPIBase("https://api.eu.mailgun.net/v3")
}
m := mailgun.NewMessage(p.Collection.DisplayTitle()+" <"+p.Collection.Alias+"@"+app.cfg.Email.Domain+">", stripmd.Strip(p.DisplayTitle()), plainMsg)
replyTo := app.db.GetCollectionAttribute(collID, collAttrLetterReplyTo)
if replyTo != "" {

@ -36,6 +36,9 @@ func New(eCfg config.EmailCfg) (*Mailer, error) {
m := &Mailer{}
if eCfg.Domain != "" && eCfg.MailgunPrivate != "" {
m.mailGun = mailgun.NewMailgun(eCfg.Domain, eCfg.MailgunPrivate)
if eCfg.MailgunEurope {
m.mailGun.SetAPIBase("https://api.eu.mailgun.net/v3")
}
} else if eCfg.Username != "" && eCfg.Password != "" && eCfg.Host != "" && eCfg.Port > 0 {
m.smtp = mail.NewSMTPClient()
m.smtp.Host = eCfg.Host

Loading…
Cancel
Save