截取邮箱名做发件名防止出现空名
This commit is contained in:
@@ -45,13 +45,15 @@ export async function email(message, env, ctx) {
|
|||||||
|
|
||||||
const email = await PostalMime.parse(content);
|
const email = await PostalMime.parse(content);
|
||||||
|
|
||||||
|
console.log(email)
|
||||||
|
|
||||||
const toName = email.to.find(item => item.address === message.to)?.name || '';
|
const toName = email.to.find(item => item.address === message.to)?.name || '';
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
toEmail: message.to,
|
toEmail: message.to,
|
||||||
toName: toName,
|
toName: toName,
|
||||||
sendEmail: email.from.address,
|
sendEmail: email.from.address,
|
||||||
name: email.from.name,
|
name: email.from.name || emailUtils.getName(email.from.address),
|
||||||
subject: email.subject,
|
subject: email.subject,
|
||||||
content: email.html,
|
content: email.html,
|
||||||
text: email.text,
|
text: email.text,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import settingService from '../service/setting-service';
|
import settingService from '../service/setting-service';
|
||||||
import emailUtils from '../utils/email-utils';
|
import emailUtils from '../utils/email-utils';
|
||||||
|
import {emailConst} from "../const/entity-const";
|
||||||
const init = {
|
const init = {
|
||||||
async init(c) {
|
async init(c) {
|
||||||
|
|
||||||
@@ -13,10 +14,15 @@ const init = {
|
|||||||
await this.v1_1DB(c);
|
await this.v1_1DB(c);
|
||||||
await this.v1_2DB(c);
|
await this.v1_2DB(c);
|
||||||
await this.v1_3DB(c);
|
await this.v1_3DB(c);
|
||||||
|
await this.v1_3_1DB(c);
|
||||||
await settingService.refresh(c);
|
await settingService.refresh(c);
|
||||||
return c.text('初始化成功');
|
return c.text('初始化成功');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async v1_3_1DB(c) {
|
||||||
|
await c.env.db.prepare(`UPDATE email SET name = SUBSTR(send_email, 1, INSTR(send_email, '@') - 1) WHERE (name IS NULL OR name = '') AND type = ${emailConst.type.RECEIVE}`).run();
|
||||||
|
},
|
||||||
|
|
||||||
async v1_3DB(c) {
|
async v1_3DB(c) {
|
||||||
|
|
||||||
const ADD_COLUMN_SQL_LIST = [
|
const ADD_COLUMN_SQL_LIST = [
|
||||||
|
|||||||
Reference in New Issue
Block a user