mirror of
https://github.com/eleith/emailjs.git
synced 2024-07-05 20:10:37 +00:00
smtp: strongly type addressparser & emailjs-mime-codec
This commit is contained in:
parent
93f23cdc11
commit
106e5bab8f
@ -1,4 +1,3 @@
|
||||
// @ts-ignore
|
||||
import addressparser from 'addressparser';
|
||||
import { Message } from './message';
|
||||
import type { MessageAttachment, MessageHeaders } from './message'; // eslint-disable-line no-unused-vars
|
||||
@ -12,7 +11,7 @@ export interface MessageStack {
|
||||
text: string;
|
||||
returnPath: string;
|
||||
from: string;
|
||||
to: string | { address: string }[];
|
||||
to: ReturnType<typeof addressparser>;
|
||||
cc: string[];
|
||||
bcc: string[];
|
||||
}
|
||||
|
@ -3,9 +3,7 @@ import { hostname } from 'os';
|
||||
import { Stream } from 'stream';
|
||||
import type { Duplex } from 'stream'; // eslint-disable-line no-unused-vars
|
||||
import type { Indexed } from '@ledge/types'; // eslint-disable-line no-unused-vars
|
||||
// @ts-ignore
|
||||
import addressparser from 'addressparser';
|
||||
// @ts-ignore
|
||||
import { mimeWordEncode } from 'emailjs-mime-codec';
|
||||
|
||||
import { getRFC2822Date } from './date';
|
||||
@ -80,7 +78,7 @@ function generate_boundary() {
|
||||
|
||||
function convertPersonToAddress(person: string) {
|
||||
return addressparser(person)
|
||||
.map(({ name, address }: { name: string; address: string }) => {
|
||||
.map(({ name, address }) => {
|
||||
return name
|
||||
? `${mimeWordEncode(name).replace(/,/g, '=2C')} <${address}>`
|
||||
: address;
|
||||
|
11
smtp/typings.d.ts
vendored
Normal file
11
smtp/typings.d.ts
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
declare module 'addressparser' {
|
||||
var addressparser: (address?: string) => { name: string; address: string }[];
|
||||
export = addressparser;
|
||||
}
|
||||
|
||||
declare module 'emailjs-mime-codec' {
|
||||
var codec: {
|
||||
mimeWordEncode: (word?: string) => string;
|
||||
};
|
||||
export = codec;
|
||||
}
|
Loading…
Reference in New Issue
Block a user