BillionMail gives you open-source MailServer, NewsLetter, Email Marketing — fully self-hosted, dev-friendly, and free from monthly fees. Join the discord: https://discord.gg/asfXzBUhZr
The unified unsubscribe link should be prioritized to use the domain name
lotk5ee02591f932
diff --git a/core/internal/controller/batch_mail/batch_mail_v1_api_mail_send.go b/core/internal/controller/batch_mail/batch_mail_v1_api_mail_send.goindex 578a0149..15c3c578 100644--- a/core/internal/controller/batch_mail/batch_mail_v1_api_mail_send.go+++ b/core/internal/controller/batch_mail/batch_mail_v1_api_mail_send.go@@ -237,7 +237,8 @@ func processMailContentAndSubject(ctx context.Context, content, subject string,if !strings.Contains(content, "__UNSUBSCRIBE_URL__") && !strings.Contains(content, "{{ UnsubscribeURL . }}") {content = public.AddUnsubscribeButton(content)}- domain := domains.GetBaseURLBySender(req.Addresser)+ //domain := domains.GetBaseURLBySender(req.Addresser)+ domain := domains.GetBaseURL()unsubscribeURL := fmt.Sprintf("%s/api/unsubscribe", domain)groupURL := fmt.Sprintf("%s/api/unsubscribe/user_group", domain)jwtToken, _ := batch_mail.GenerateUnsubscribeJWT(req.Recipient, apiTemplate.TemplateId, apiTemplate.Id)@@ -283,7 +284,8 @@ func sendApiMail(ctx context.Context, apiTemplate *entity.ApiTemplates, subject,// generate message IDmessageId := sender.GenerateMessageID()// add 1 billion to prevent conflict with marketing task id- baseURL := domains.GetBaseURLBySender(addresser)+ //baseURL := domains.GetBaseURLBySender(addresser)+ baseURL := domains.GetBaseURL()apiTemplate_id := apiTemplate.Id + 1000000000mailTracker := maillog_stat.NewMailTracker(content, apiTemplate_id, messageId, recipient, baseURL)mailTracker.TrackLinks()diff --git a/core/internal/controller/subscribe_list/subscribe_list.go b/core/internal/controller/subscribe_list/subscribe_list.goindex 7f03a6da..dd52cf9c 100644--- a/core/internal/controller/subscribe_list/subscribe_list.go+++ b/core/internal/controller/subscribe_list/subscribe_list.go@@ -173,17 +173,6 @@ func sendMail(ctx context.Context, emailHtml, email, subject, confirmUrl string)// 3. Handle unsubscribe linkcontent := emailHtml- //if !strings.Contains(content, "{{ UnsubscribeURL . }}") {- // content = public.AddUnsubscribeButton(content)- //}-- //// 4. Generate unsubscribe JWT and link- //jwtToken, _ := batch_mail.GenerateUnsubscribeJWT(email, templateId, 0)- //domain := domains.GetBaseURL()- //unsubscribeURL := fmt.Sprintf("%s/api/unsubscribe", domain)- //groupURL := fmt.Sprintf("%s/api/unsubscribe/user_group", domain)- //unsubscribeJumpURL := fmt.Sprintf("%s/unsubscribe.html?jwt=%s&email=%s&url_type=%s&url_unsubscribe=%s",- // domain, jwtToken, email, groupURL, unsubscribeURL)// 5. Render content and subjectengine := batch_mail.GetTemplateEngine()diff --git a/core/internal/service/batch_mail/api_mail_send.go b/core/internal/service/batch_mail/api_mail_send.goindex 248d604b..6aa1e8fd 100644--- a/core/internal/service/batch_mail/api_mail_send.go+++ b/core/internal/service/batch_mail/api_mail_send.go@@ -330,7 +330,8 @@ func ProcessApiMailQueue(ctx context.Context) {func sendApiMailWithSender(ctx context.Context, apiTemplate *entity.ApiTemplates, subject string, content string, log ApiMailLog, sender *mail_service.EmailSender) error {// generate message IDmessageId := "<" + log.MessageId + ">"- baseURL := domains.GetBaseURLBySender(log.Addresser)+ //baseURL := domains.GetBaseURLBySender(log.Addresser)+ baseURL := domains.GetBaseURL()apiTemplate_id := apiTemplate.Id + 1000000000mailTracker := maillog_stat.NewMailTracker(content, apiTemplate_id, messageId, log.Recipient, baseURL)mailTracker.TrackLinks()@@ -424,7 +425,8 @@ func sendApiMail(ctx context.Context, apiTemplate *entity.ApiTemplates, subjectmessageId := "<" + log.MessageId + ">"// add 1 billion to prevent conflict with marketing task id- baseURL := domains.GetBaseURLBySender(log.Addresser)+ //baseURL := domains.GetBaseURLBySender(log.Addresser)+ baseURL := domains.GetBaseURL()apiTemplate_id := apiTemplate.Id + 1000000000mailTracker := maillog_stat.NewMailTracker(content, apiTemplate_id, messageId, log.Recipient, baseURL)mailTracker.TrackLinks()@@ -479,7 +481,8 @@ func processMailContentAndSubject(ctx context.Context, content, subject string,if !strings.Contains(content, "__UNSUBSCRIBE_URL__") && !strings.Contains(content, "{{ UnsubscribeURL . }}") {content = public.AddUnsubscribeButton(content)}- domain := domains.GetBaseURLBySender(log.Addresser)+ //domain := domains.GetBaseURLBySender(log.Addresser)+ domain := domains.GetBaseURL()unsubscribeURL := fmt.Sprintf("%s/api/unsubscribe", domain)groupURL := fmt.Sprintf("%s/api/unsubscribe/user_group", domain)jwtToken, _ := GenerateUnsubscribeJWT(log.Recipient, apiTemplate.TemplateId, apiTemplate.Id)diff --git a/core/internal/service/batch_mail/task_executor.go b/core/internal/service/batch_mail/task_executor.goindex cbf7ce75..8f37f3e3 100644--- a/core/internal/service/batch_mail/task_executor.go+++ b/core/internal/service/batch_mail/task_executor.go@@ -945,7 +945,8 @@ func (e *TaskExecutor) personalizeEmail(ctx context.Context, content string, tasengine := GetTemplateEngine()if task.Unsubscribe == 1 {- domain := domains.GetBaseURLBySender(task.Addresser)+ //domain := domains.GetBaseURLBySender(task.Addresser)+ domain := domains.GetBaseURL()unsubscribeURL := fmt.Sprintf("%s/api/unsubscribe", domain)groupURL := fmt.Sprintf("%s/api/unsubscribe/user_group", domain)@@ -1026,7 +1027,8 @@ func (e *TaskExecutor) sendEmail(ctx context.Context, task *entity.EmailTask, remessageID := sender.GenerateMessageID()//Tracking emails- baseURL := domains.GetBaseURLBySender(task.Addresser)+ //baseURL := domains.GetBaseURLBySender(task.Addresser)+ baseURL := domains.GetBaseURL()mail_tracker := maillog_stat.NewMailTracker(renderedContent, task.Id, messageID, recipient.Recipient, baseURL)mail_tracker.TrackLinks()mail_tracker.AppendTrackingPixel()@@ -1091,7 +1093,8 @@ func (e *TaskExecutor) sendEmailMock(ctx context.Context, task *entity.EmailTaskmessageID := sender.GenerateMessageID()// Track email- baseURL := domains.GetBaseURLBySender(task.Addresser)+ //baseURL := domains.GetBaseURLBySender(task.Addresser)+ baseURL := domains.GetBaseURL()mail_tracker := maillog_stat.NewMailTracker(renderedContent, task.Id, messageID, recipient.Recipient, baseURL)mail_tracker.TrackLinks()mail_tracker.AppendTrackingPixel()