diff --git a/db/db_mysql/migrations/20180226133237_0.4.1_envelope_sender.sql b/db/db_mysql/migrations/20180226133237_0.4.1_envelope_sender.sql new file mode 100644 index 00000000..ca874545 --- /dev/null +++ b/db/db_mysql/migrations/20180226133237_0.4.1_envelope_sender.sql @@ -0,0 +1,8 @@ + +-- +goose Up +-- SQL in section 'Up' is executed when this migration is applied +ALTER TABLE templates ADD COLUMN envelope_sender varchar(255); + +-- +goose Down +-- SQL section 'Down' is executed when this migration is rolled back + diff --git a/db/db_sqlite3/migrations/20180226133237_0.4.1_envelope_sender.sql b/db/db_sqlite3/migrations/20180226133237_0.4.1_envelope_sender.sql new file mode 100644 index 00000000..ca874545 --- /dev/null +++ b/db/db_sqlite3/migrations/20180226133237_0.4.1_envelope_sender.sql @@ -0,0 +1,8 @@ + +-- +goose Up +-- SQL in section 'Up' is executed when this migration is applied +ALTER TABLE templates ADD COLUMN envelope_sender varchar(255); + +-- +goose Down +-- SQL section 'Down' is executed when this migration is rolled back + diff --git a/mailer/mailer.go b/mailer/mailer.go index 981d90d3..fb24833e 100644 --- a/mailer/mailer.go +++ b/mailer/mailer.go @@ -51,6 +51,7 @@ type Mail interface { Success() error Generate(msg *gomail.Message) error GetDialer() (Dialer, error) + GetSmtpFrom() (string, error) } // Mailer is a global instance of the mailer that can @@ -161,7 +162,13 @@ func sendMail(ctx context.Context, dialer Dialer, ms []Mail) { continue } - err = gomail.Send(sender, message) + smtp_from, err := m.GetSmtpFrom() + if err != nil { + m.Error(err) + continue + } + + err = gomail.SendCustomFrom(sender, smtp_from, message) if err != nil { if te, ok := err.(*textproto.Error); ok { switch { diff --git a/mailer/mockmailer.go b/mailer/mockmailer.go index a5fc230d..1bbbc389 100644 --- a/mailer/mockmailer.go +++ b/mailer/mockmailer.go @@ -170,6 +170,10 @@ func (mm *mockMessage) Generate(message *gomail.Message) error { return nil } +func (mm *mockMessage) GetSmtpFrom() (string, error) { + return mm.from, nil +} + func (mm *mockMessage) Success() error { mm.finished = true return nil diff --git a/models/email_request.go b/models/email_request.go index 8ddb10e2..9068425e 100644 --- a/models/email_request.go +++ b/models/email_request.go @@ -56,9 +56,14 @@ func (s *SendTestEmailRequest) Success() error { return nil } +func (s *SendTestEmailRequest) GetSmtpFrom() (string, error) { + return s.SMTP.FromAddress, nil +} + // Generate fills in the details of a gomail.Message with the contents // from the SendTestEmailRequest. func (s *SendTestEmailRequest) Generate(msg *gomail.Message) error { + // Naively use the SMTP-from as the Envelope-from for this test message f, err := mail.ParseAddress(s.SMTP.FromAddress) if err != nil { return err diff --git a/models/email_request_test.go b/models/email_request_test.go index 542c47f8..89f6db9c 100644 --- a/models/email_request_test.go +++ b/models/email_request_test.go @@ -94,6 +94,35 @@ func (s *ModelsSuite) TestEmailRequestGenerate(ch *check.C) { ch.Assert(string(got.HTML), check.Equals, string(expected.HTML)) } +func (s *ModelsSuite) TestGetSmtpFrom(ch *check.C) { + smtp := SMTP{ + FromAddress: "from@example.com", + } + template := Template{ + Name: "Test Template", + Subject: "{{.FirstName}} - Subject", + Text: "{{.Email}} - Text", + HTML: "{{.Email}} - HTML", + } + target := Target{ + FirstName: "First", + LastName: "Last", + Email: "firstlast@example.com", + } + req := &SendTestEmailRequest{ + SMTP: smtp, + Template: template, + Target: target, + } + + msg := gomail.NewMessage() + err = req.Generate(msg) + smtp_from, err := req.GetSmtpFrom() + + ch.Assert(err, check.Equals, nil) + ch.Assert(smtp_from, check.Equals, "from@example.com") +} + func (s *ModelsSuite) TestEmailRequestURLTemplating(ch *check.C) { smtp := SMTP{ FromAddress: "from@example.com", @@ -113,7 +142,7 @@ func (s *ModelsSuite) TestEmailRequestURLTemplating(ch *check.C) { SMTP: smtp, Template: template, Target: target, - URL: "http://127.0.0.1/{{.Email}}", + URL: "http://127.0.0.1/{{.Email}}", } msg := gomail.NewMessage() diff --git a/models/maillog.go b/models/maillog.go index 8ed9741e..5cd14004 100644 --- a/models/maillog.go +++ b/models/maillog.go @@ -193,6 +193,16 @@ func buildTemplate(text string, data interface{}) (string, error) { return buff.String(), err } +func (m *MailLog) GetSmtpFrom() (string, error) { + c, err := GetCampaign(m.CampaignId, m.UserId) + if err != nil { + return "", err + } + + f, err := mail.ParseAddress(c.SMTP.FromAddress) + return f.Address, err +} + // Generate fills in the details of a gomail.Message instance with // the correct headers and body from the campaign and recipient listed in // the maillog. We accept the gomail.Message as an argument so that the caller @@ -206,9 +216,13 @@ func (m *MailLog) Generate(msg *gomail.Message) error { if err != nil { return err } - f, err := mail.ParseAddress(c.SMTP.FromAddress) + + f, err := mail.ParseAddress(c.Template.EnvelopeSender) if err != nil { - return err + f, err = mail.ParseAddress(c.SMTP.FromAddress) + if err != nil { + return err + } } fn := f.Name if fn == "" { diff --git a/models/maillog_test.go b/models/maillog_test.go index f77be871..f56a8c2d 100644 --- a/models/maillog_test.go +++ b/models/maillog_test.go @@ -188,6 +188,40 @@ func (s *ModelsSuite) TestGenerateMailLog(ch *check.C) { ch.Assert(m.Processing, check.Equals, false) } +func (s *ModelsSuite) TestMailLogGetSmtpFrom(ch *check.C) { + template := Template{ + Name: "OverrideSmtpFrom", + UserId: 1, + Text: "dummytext", + HTML: "Dummyhtml", + Subject: "Dummysubject", + EnvelopeSender: "spoofing@example.com", + } + ch.Assert(PostTemplate(&template), check.Equals, nil) + campaign := s.createCampaignDependencies(ch) + campaign.Template = template + + ch.Assert(PostCampaign(&campaign, campaign.UserId), check.Equals, nil) + result := campaign.Results[0] + + m := &MailLog{} + err := db.Where("r_id=? AND campaign_id=?", result.RId, campaign.Id). + Find(m).Error + ch.Assert(err, check.Equals, nil) + + msg := gomail.NewMessage() + err = m.Generate(msg) + ch.Assert(err, check.Equals, nil) + + msgBuff := &bytes.Buffer{} + _, err = msg.WriteTo(msgBuff) + ch.Assert(err, check.Equals, nil) + + got, err := email.NewEmailFromReader(msgBuff) + ch.Assert(err, check.Equals, nil) + ch.Assert(got.From, check.Equals, "spoofing@example.com") +} + func (s *ModelsSuite) TestMailLogGenerate(ch *check.C) { campaign := s.createCampaign(ch) result := campaign.Results[0] @@ -201,6 +235,7 @@ func (s *ModelsSuite) TestMailLogGenerate(ch *check.C) { ch.Assert(err, check.Equals, nil) expected := &email.Email{ + From: "test@test.com", // Default smtp.FromAddress Subject: fmt.Sprintf("%s - Subject", result.RId), Text: []byte(fmt.Sprintf("%s - Text", result.RId)), HTML: []byte(fmt.Sprintf("%s - HTML", result.RId)), @@ -212,6 +247,7 @@ func (s *ModelsSuite) TestMailLogGenerate(ch *check.C) { got, err := email.NewEmailFromReader(msgBuff) ch.Assert(err, check.Equals, nil) + ch.Assert(got.From, check.Equals, expected.From) ch.Assert(got.Subject, check.Equals, expected.Subject) ch.Assert(string(got.Text), check.Equals, string(expected.Text)) ch.Assert(string(got.HTML), check.Equals, string(expected.HTML)) diff --git a/models/template.go b/models/template.go index dbb24dc0..5a22ebfa 100644 --- a/models/template.go +++ b/models/template.go @@ -4,6 +4,7 @@ import ( "bytes" "errors" "html/template" + "net/mail" "time" "github.com/jinzhu/gorm" @@ -11,14 +12,15 @@ import ( // Template models hold the attributes for an email template to be sent to targets type Template struct { - Id int64 `json:"id" gorm:"column:id; primary_key:yes"` - UserId int64 `json:"-" gorm:"column:user_id"` - Name string `json:"name"` - Subject string `json:"subject"` - Text string `json:"text"` - HTML string `json:"html" gorm:"column:html"` - ModifiedDate time.Time `json:"modified_date"` - Attachments []Attachment `json:"attachments"` + Id int64 `json:"id" gorm:"column:id; primary_key:yes"` + UserId int64 `json:"-" gorm:"column:user_id"` + Name string `json:"name"` + EnvelopeSender string `json:"envelope_sender"` + Subject string `json:"subject"` + Text string `json:"text"` + HTML string `json:"html" gorm:"column:html"` + ModifiedDate time.Time `json:"modified_date"` + Attachments []Attachment `json:"attachments"` } // ErrTemplateNameNotSpecified is thrown when a template name is not specified @@ -34,6 +36,11 @@ func (t *Template) Validate() error { return ErrTemplateNameNotSpecified case t.Text == "" && t.HTML == "": return ErrTemplateMissingParameter + case t.EnvelopeSender != "": + _, err := mail.ParseAddress(t.EnvelopeSender) + if err != nil { + return err + } } var buff bytes.Buffer // Test that the variables used in the template diff --git a/static/js/dist/app/templates.min.js b/static/js/dist/app/templates.min.js index fbd104da..c2d6b750 100644 --- a/static/js/dist/app/templates.min.js +++ b/static/js/dist/app/templates.min.js @@ -1 +1 @@ -function save(a){var t={attachments:[]};t.name=$("#name").val(),t.subject=$("#subject").val(),t.html=CKEDITOR.instances.html_editor.getData(),t.html=t.html.replace(/https?:\/\/{{\.URL}}/gi,"{{.URL}}"),$("#use_tracker_checkbox").prop("checked")?t.html.indexOf("{{.Tracker}}")==-1&&t.html.indexOf("{{.TrackingUrl}}")==-1&&(t.html=t.html.replace("","{{.Tracker}}")):t.html=t.html.replace("{{.Tracker}}",""),t.text=$("#text_editor").val(),$.each($("#attachmentsTable").DataTable().rows().data(),function(a,e){t.attachments.push({name:unescapeHtml(e[1]),content:e[3],type:e[4]})}),a!=-1?(t.id=templates[a].id,api.templateId.put(t).success(function(a){successFlash("Template edited successfully!"),load(),dismiss()}).error(function(a){modalError(a.responseJSON.message)})):api.templates.post(t).success(function(a){successFlash("Template added successfully!"),load(),dismiss()}).error(function(a){modalError(a.responseJSON.message)})}function dismiss(){$("#modal\\.flashes").empty(),$("#attachmentsTable").dataTable().DataTable().clear().draw(),$("#name").val(""),$("#subject").val(""),$("#text_editor").val(""),$("#html_editor").val(""),$("#modal").modal("hide")}function deleteTemplate(a){confirm("Delete "+templates[a].name+"?")&&api.templateId.delete(templates[a].id).success(function(a){successFlash(a.message),load()})}function attach(a){attachmentsTable=$("#attachmentsTable").DataTable({destroy:!0,order:[[1,"asc"]],columnDefs:[{orderable:!1,targets:"no-sort"},{sClass:"datatable_hidden",targets:[3,4]}]}),$.each(a,function(a,t){var e=new FileReader;e.onload=function(a){var o=icons[t.type]||"fa-file-o";attachmentsTable.row.add(['',escapeHtml(t.name),'',e.result.split(",")[1],t.type||"application/octet-stream"]).draw()},e.onerror=function(a){console.log(a)},e.readAsDataURL(t)})}function edit(a){$("#modalSubmit").unbind("click").click(function(){save(a)}),$("#attachmentUpload").unbind("click").click(function(){this.value=null}),$("#html_editor").ckeditor(),$("#attachmentsTable").show(),attachmentsTable=$("#attachmentsTable").DataTable({destroy:!0,order:[[1,"asc"]],columnDefs:[{orderable:!1,targets:"no-sort"},{sClass:"datatable_hidden",targets:[3,4]}]});var t={attachments:[]};a!=-1&&(t=templates[a],$("#name").val(t.name),$("#subject").val(t.subject),$("#html_editor").val(t.html),$("#text_editor").val(t.text),$.each(t.attachments,function(a,t){var e=icons[t.type]||"fa-file-o";attachmentsTable.row.add(['',escapeHtml(t.name),'',t.content,t.type||"application/octet-stream"]).draw()}),t.html.indexOf("{{.Tracker}}")!=-1?$("#use_tracker_checkbox").prop("checked",!0):$("#use_tracker_checkbox").prop("checked",!1)),$("#attachmentsTable").unbind("click").on("click","span>i.fa-trash-o",function(){attachmentsTable.row($(this).parents("tr")).remove().draw()})}function copy(a){$("#modalSubmit").unbind("click").click(function(){save(-1)}),$("#attachmentUpload").unbind("click").click(function(){this.value=null}),$("#html_editor").ckeditor(),$("#attachmentsTable").show(),attachmentsTable=$("#attachmentsTable").DataTable({destroy:!0,order:[[1,"asc"]],columnDefs:[{orderable:!1,targets:"no-sort"},{sClass:"datatable_hidden",targets:[3,4]}]});var t={attachments:[]};t=templates[a],$("#name").val("Copy of "+t.name),$("#subject").val(t.subject),$("#html_editor").val(t.html),$("#text_editor").val(t.text),$.each(t.attachments,function(a,t){var e=icons[t.type]||"fa-file-o";attachmentsTable.row.add(['',escapeHtml(t.name),'',t.content,t.type||"application/octet-stream"]).draw()}),$("#attachmentsTable").unbind("click").on("click","span>i.fa-trash-o",function(){attachmentsTable.row($(this).parents("tr")).remove().draw()}),t.html.indexOf("{{.Tracker}}")!=-1?$("#use_tracker_checkbox").prop("checked",!0):$("#use_tracker_checkbox").prop("checked",!1)}function importEmail(){raw=$("#email_content").val(),convert_links=$("#convert_links_checkbox").prop("checked"),raw?api.import_email({content:raw,convert_links:convert_links}).success(function(a){$("#text_editor").val(a.text),$("#html_editor").val(a.html),$("#subject").val(a.subject),$("#importEmailModal").modal("hide")}).error(function(a){modalError(a.responseJSON.message)}):modalError("No Content Specified!")}function load(){$("#templateTable").hide(),$("#emptyMessage").hide(),$("#loading").show(),api.templates.get().success(function(a){templates=a,$("#loading").hide(),templates.length>0?($("#templateTable").show(),templateTable=$("#templateTable").DataTable({destroy:!0,columnDefs:[{orderable:!1,targets:"no-sort"}]}),templateTable.clear(),$.each(templates,function(a,t){templateTable.row.add([escapeHtml(t.name),moment(t.modified_date).format("MMMM Do YYYY, h:mm:ss a"),"
\t\t
"]).draw()}),$('[data-toggle="tooltip"]').tooltip()):$("#emptyMessage").show()}).error(function(){$("#loading").hide(),errorFlash("Error fetching templates")})}var templates=[],icons={"application/vnd.ms-excel":"fa-file-excel-o","text/plain":"fa-file-text-o","image/gif":"fa-file-image-o","image/png":"fa-file-image-o","application/pdf":"fa-file-pdf-o","application/x-zip-compressed":"fa-file-archive-o","application/x-gzip":"fa-file-archive-o","application/vnd.openxmlformats-officedocument.presentationml.presentation":"fa-file-powerpoint-o","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"fa-file-word-o","application/octet-stream":"fa-file-o","application/x-msdownload":"fa-file-o"};$(document).ready(function(){$(".modal").on("hidden.bs.modal",function(a){$(this).removeClass("fv-modal-stack"),$("body").data("fv_open_modals",$("body").data("fv_open_modals")-1)}),$(".modal").on("shown.bs.modal",function(a){"undefined"==typeof $("body").data("fv_open_modals")&&$("body").data("fv_open_modals",0),$(this).hasClass("fv-modal-stack")||($(this).addClass("fv-modal-stack"),$("body").data("fv_open_modals",$("body").data("fv_open_modals")+1),$(this).css("z-index",1040+10*$("body").data("fv_open_modals")),$(".modal-backdrop").not(".fv-modal-stack").css("z-index",1039+10*$("body").data("fv_open_modals")),$(".modal-backdrop").not("fv-modal-stack").addClass("fv-modal-stack"))}),$.fn.modal.Constructor.prototype.enforceFocus=function(){$(document).off("focusin.bs.modal").on("focusin.bs.modal",$.proxy(function(a){this.$element[0]===a.target||this.$element.has(a.target).length||$(a.target).closest(".cke_dialog, .cke").length||this.$element.trigger("focus")},this))},$(document).on("hidden.bs.modal",".modal",function(){$(".modal:visible").length&&$(document.body).addClass("modal-open")}),$("#modal").on("hidden.bs.modal",function(a){dismiss()}),$("#importEmailModal").on("hidden.bs.modal",function(a){$("#email_content").val("")}),load()}); \ No newline at end of file +function save(a){var t={attachments:[]};t.name=$("#name").val(),t.subject=$("#subject").val(),t.html=CKEDITOR.instances.html_editor.getData(),t.html=t.html.replace(/https?:\/\/{{\.URL}}/gi,"{{.URL}}"),$("#use_tracker_checkbox").prop("checked")?t.html.indexOf("{{.Tracker}}")==-1&&t.html.indexOf("{{.TrackingUrl}}")==-1&&(t.html=t.html.replace("","{{.Tracker}}")):t.html=t.html.replace("{{.Tracker}}",""),t.text=$("#text_editor").val(),$.each($("#attachmentsTable").DataTable().rows().data(),function(a,e){t.attachments.push({name:unescapeHtml(e[1]),content:e[3],type:e[4]})}),a!=-1?(t.id=templates[a].id,api.templateId.put(t).success(function(a){successFlash("Template edited successfully!"),load(),dismiss()}).error(function(a){modalError(a.responseJSON.message)})):api.templates.post(t).success(function(a){successFlash("Template added successfully!"),load(),dismiss()}).error(function(a){modalError(a.responseJSON.message)})}function dismiss(){$("#modal\\.flashes").empty(),$("#attachmentsTable").dataTable().DataTable().clear().draw(),$("#name").val(""),$("#subject").val(""),$("#text_editor").val(""),$("#html_editor").val(""),$("#modal").modal("hide")}function deleteTemplate(a){confirm("Delete "+templates[a].name+"?")&&api.templateId.delete(templates[a].id).success(function(a){successFlash(a.message),load()})}function attach(a){attachmentsTable=$("#attachmentsTable").DataTable({destroy:!0,order:[[1,"asc"]],columnDefs:[{orderable:!1,targets:"no-sort"},{sClass:"datatable_hidden",targets:[3,4]}]}),$.each(a,function(a,t){var e=new FileReader;e.onload=function(a){var o=icons[t.type]||"fa-file-o";attachmentsTable.row.add(['',escapeHtml(t.name),'',e.result.split(",")[1],t.type||"application/octet-stream"]).draw()},e.onerror=function(a){console.log(a)},e.readAsDataURL(t)})}function edit(a){$("#modalSubmit").unbind("click").click(function(){save(a)}),$("#attachmentUpload").unbind("click").click(function(){this.value=null}),$("#html_editor").ckeditor(),$("#attachmentsTable").show(),attachmentsTable=$("#attachmentsTable").DataTable({destroy:!0,order:[[1,"asc"]],columnDefs:[{orderable:!1,targets:"no-sort"},{sClass:"datatable_hidden",targets:[3,4]}]});var t={attachments:[]};a!=-1&&(t=templates[a],$("#name").val(t.name),$("#subject").val(t.subject),$("#html_editor").val(t.html),$("#text_editor").val(t.text),$.each(t.attachments,function(a,t){var e=icons[t.type]||"fa-file-o";attachmentsTable.row.add(['',escapeHtml(t.name),'',t.content,t.type||"application/octet-stream"]).draw()}),t.html.indexOf("{{.Tracker}}")!=-1?$("#use_tracker_checkbox").prop("checked",!0):$("#use_tracker_checkbox").prop("checked",!1)),$("#attachmentsTable").unbind("click").on("click","span>i.fa-trash-o",function(){attachmentsTable.row($(this).parents("tr")).remove().draw()})}function copy(a){$("#modalSubmit").unbind("click").click(function(){save(-1)}),$("#attachmentUpload").unbind("click").click(function(){this.value=null}),$("#html_editor").ckeditor(),$("#attachmentsTable").show(),attachmentsTable=$("#attachmentsTable").DataTable({destroy:!0,order:[[1,"asc"]],columnDefs:[{orderable:!1,targets:"no-sort"},{sClass:"datatable_hidden",targets:[3,4]}]});var t={attachments:[]};t=templates[a],$("#name").val("Copy of "+t.name),$("#subject").val(t.subject),$("#html_editor").val(t.html),$("#text_editor").val(t.text),$.each(t.attachments,function(a,t){var e=icons[t.type]||"fa-file-o";attachmentsTable.row.add(['',escapeHtml(t.name),'',t.content,t.type||"application/octet-stream"]).draw()}),$("#attachmentsTable").unbind("click").on("click","span>i.fa-trash-o",function(){attachmentsTable.row($(this).parents("tr")).remove().draw()}),t.html.indexOf("{{.Tracker}}")!=-1?$("#use_tracker_checkbox").prop("checked",!0):$("#use_tracker_checkbox").prop("checked",!1)}function importEmail(){raw=$("#email_content").val(),convert_links=$("#convert_links_checkbox").prop("checked"),raw?api.import_email({content:raw,convert_links:convert_links}).success(function(a){$("#text_editor").val(a.text),$("#html_editor").val(a.html),$("#subject").val(a.subject),$("#importEmailModal").modal("hide")}).error(function(a){modalError(a.responseJSON.message)}):modalError("No Content Specified!")}function load(){$("#templateTable").hide(),$("#emptyMessage").hide(),$("#loading").show(),api.templates.get().success(function(a){templates=a,$("#loading").hide(),templates.length>0?($("#templateTable").show(),templateTable=$("#templateTable").DataTable({destroy:!0,columnDefs:[{orderable:!1,targets:"no-sort"}]}),templateTable.clear(),$.each(templates,function(a,t){templateTable.row.add([escapeHtml(t.name),moment(t.modified_date).format("MMMM Do YYYY, h:mm:ss a"),"
\t\t
"]).draw()}),$('[data-toggle="tooltip"]').tooltip()):$("#emptyMessage").show()}).error(function(){$("#loading").hide(),errorFlash("Error fetching templates")})}var templates=[],icons={"application/vnd.ms-excel":"fa-file-excel-o","text/plain":"fa-file-text-o","image/gif":"fa-file-image-o","image/png":"fa-file-image-o","application/pdf":"fa-file-pdf-o","application/x-zip-compressed":"fa-file-archive-o","application/x-gzip":"fa-file-archive-o","application/vnd.openxmlformats-officedocument.presentationml.presentation":"fa-file-powerpoint-o","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"fa-file-word-o","application/octet-stream":"fa-file-o","application/x-msdownload":"fa-file-o"};$(document).ready(function(){$(".modal").on("hidden.bs.modal",function(a){$(this).removeClass("fv-modal-stack"),$("body").data("fv_open_modals",$("body").data("fv_open_modals")-1)}),$(".modal").on("shown.bs.modal",function(a){"undefined"==typeof $("body").data("fv_open_modals")&&$("body").data("fv_open_modals",0),$(this).hasClass("fv-modal-stack")||($(this).addClass("fv-modal-stack"),$("body").data("fv_open_modals",$("body").data("fv_open_modals")+1),$(this).css("z-index",1040+10*$("body").data("fv_open_modals")),$(".modal-backdrop").not(".fv-modal-stack").css("z-index",1039+10*$("body").data("fv_open_modals")),$(".modal-backdrop").not("fv-modal-stack").addClass("fv-modal-stack"))}),$.fn.modal.Constructor.prototype.enforceFocus=function(){$(document).off("focusin.bs.modal").on("focusin.bs.modal",$.proxy(function(a){this.$element[0]===a.target||this.$element.has(a.target).length||$(a.target).closest(".cke_dialog, .cke").length||this.$element.trigger("focus")},this))},$(document).on("hidden.bs.modal",".modal",function(){$(".modal:visible").length&&$(document.body).addClass("modal-open")}),$("#modal").on("hidden.bs.modal",function(a){dismiss()}),$("#importEmailModal").on("hidden.bs.modal",function(a){$("#email_content").val("")}),load()}); diff --git a/static/js/src/app/templates.js b/static/js/src/app/templates.js index d5c14b83..27ed6cfb 100644 --- a/static/js/src/app/templates.js +++ b/static/js/src/app/templates.js @@ -20,6 +20,7 @@ function save(idx) { } template.name = $("#name").val() template.subject = $("#subject").val() + template.envelope_sender = $("#envelope-sender").val() template.html = CKEDITOR.instances["html_editor"].getData(); // Fix the URL Scheme added by CKEditor (until we can remove it from the plugin) template.html = template.html.replace(/https?:\/\/{{\.URL}}/gi, "{{.URL}}") @@ -152,6 +153,7 @@ function edit(idx) { template = templates[idx] $("#name").val(template.name) $("#subject").val(template.subject) + $("#envelope-sender").val(template.envelope_sender) $("#html_editor").val(template.html) $("#text_editor").val(template.text) $.each(template.attachments, function (i, file) { @@ -208,6 +210,7 @@ function copy(idx) { template = templates[idx] $("#name").val("Copy of " + template.name) $("#subject").val(template.subject) + $("#envelope-sender").val(template.envelope_sender) $("#html_editor").val(template.html) $("#text_editor").val(template.text) $.each(template.attachments, function (i, file) { diff --git a/templates/sending_profiles.html b/templates/sending_profiles.html index a3ddbf21..41e8685d 100644 --- a/templates/sending_profiles.html +++ b/templates/sending_profiles.html @@ -74,7 +74,7 @@ - + diff --git a/templates/templates.html b/templates/templates.html index a2e82701..fcc4d50b 100644 --- a/templates/templates.html +++ b/templates/templates.html @@ -77,6 +77,10 @@
+ +
+ +