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
mail api
lotk21eeef501a63
diff --git a/core/api/batch_mail/batch_mail.go b/core/api/batch_mail/batch_mail.goindex cc3d2799..497f6b4b 100644--- a/core/api/batch_mail/batch_mail.go+++ b/core/api/batch_mail/batch_mail.go@@ -11,6 +11,11 @@ import ()type IBatchMailV1 interface {+ ApiTemplatesList(ctx context.Context, req *v1.ApiTemplatesListReq) (res *v1.ApiTemplatesListRes, err error)+ ApiTemplatesCreate(ctx context.Context, req *v1.ApiTemplatesCreateReq) (res *v1.ApiTemplatesCreateRes, err error)+ ApiTemplatesUpdate(ctx context.Context, req *v1.ApiTemplatesUpdateReq) (res *v1.ApiTemplatesUpdateRes, err error)+ ApiTemplatesDelete(ctx context.Context, req *v1.ApiTemplatesDeleteReq) (res *v1.ApiTemplatesDeleteRes, err error)+ ApiMailSend(ctx context.Context, req *v1.ApiMailSendReq) (res *v1.ApiMailSendRes, err error)ListTasks(ctx context.Context, req *v1.ListTasksReq) (res *v1.ListTasksRes, err error)DeleteTask(ctx context.Context, req *v1.DeleteTaskReq) (res *v1.DeleteTaskRes, err error)CreateTask(ctx context.Context, req *v1.CreateTaskReq) (res *v1.CreateTaskRes, err error)diff --git a/core/internal/service/database_initialization/batch_mail.go b/core/internal/service/database_initialization/batch_mail.goindex c5044a81..0477b0a9 100644--- a/core/internal/service/database_initialization/batch_mail.go+++ b/core/internal/service/database_initialization/batch_mail.go@@ -101,6 +101,32 @@ func init() {UNIQUE(recipient))`,+ `CREATE TABLE IF NOT EXISTS api_templates (+ id SERIAL PRIMARY KEY,+ api_key VARCHAR(64) NOT NULL,+ api_name VARCHAR(255) NOT NULL,+ template_id INTEGER NOT NULL,+ subject TEXT NOT NULL,+ addresser VARCHAR(320) NOT NULL,+ full_name VARCHAR(255),+ unsubscribe SMALLINT NOT NULL DEFAULT 0,+ track_open SMALLINT NOT NULL DEFAULT 1,+ track_click SMALLINT NOT NULL DEFAULT 1,+ active SMALLINT NOT NULL DEFAULT 1,+ create_time INTEGER NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()),+ update_time INTEGER NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()),+ UNIQUE(api_key)+ )`,++ `CREATE TABLE IF NOT EXISTS api_mail_logs (+ id SERIAL PRIMARY KEY,+ api_id INTEGER NOT NULL,+ recipient VARCHAR(320) NOT NULL,+ message_id TEXT NOT NULL,+ addresser VARCHAR(320) NOT NULL,+ send_time INTEGER NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW())+ )`,+`CREATE INDEX IF NOT EXISTS idx_unsubscribe_email ON unsubscribe_records (email)`,`CREATE INDEX IF NOT EXISTS idx_unsubscribe_time ON unsubscribe_records (unsubscribe_time)`,`CREATE INDEX IF NOT EXISTS idx_bm_contacts_email ON bm_contacts (email)`,@@ -131,6 +157,10 @@ func init() {ALTER TABLE bm_contacts ADD COLUMN status INTEGER DEFAULT 0;END IF;END $$;`,++ `CREATE INDEX IF NOT EXISTS idx_api_mail_logs_api_id ON api_mail_logs (api_id)`,+ `CREATE INDEX IF NOT EXISTS idx_api_mail_logs_recipient ON api_mail_logs (recipient)`,+ `CREATE INDEX IF NOT EXISTS idx_api_mail_logs_message_id ON api_mail_logs (message_id)`,}for _, sql := range batchMailSQLList {