diff --git a/config/config.go b/config/config.go index 17d34c8..8a79224 100644 --- a/config/config.go +++ b/config/config.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 diff --git a/email.go b/email.go index a44b253..7da60e4 100644 --- a/email.go +++ b/email.go @@ -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 != "" { diff --git a/mailer/mailer.go b/mailer/mailer.go index 1f9f86e..a75b585 100644 --- a/mailer/mailer.go +++ b/mailer/mailer.go @@ -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