forked from angelos3lex/react-native-smtp-mailer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
98 lines (80 loc) · 2.49 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import { NativeModules } from 'react-native';
const { RNSmtpMailer } = NativeModules;
export interface SmtpOptions {
/**
* The smtp provider host. i.e: "smtp.gmail.com"
*/
mailhost: string;
/**
* The port that the smtp provider listens to, i.e: "465"
*/
port: string;
/**
* The username to authenticate with stmp host, i.e: "[email protected]"
*/
username: string;
/**
* The password to authenticate with stmp host
*/
password: string;
/**
* Sender email
* i.e: "[email protected]"
*/
from: string;
/**
* Comma separated values if want to add multiple recipients
* i.e: "[email protected],[email protected]"
*/
recipients: string;
/**
* The subject of the email
*/
subject: string;
/**
* The body of the email.
* i.e:
* <h1>Sample Header</h1><p>Lorem ipsum dolor sit amet...</p>
*/
htmlBody: string;
/**
* Alias of the username email address, to be shown in the recipients as the sender's name.
* By default it's the same as the username field
* i.e: "[email protected]"
* *Note:* This is different than the reply-to email address. If reply-to is not specified, the reply-to will still use the username email
*/
fromName?: string;
/**
* If not specified, the reply-to email is the username one
* i.e: "[email protected]"
*/
replyTo?: string;
/**
* In iOS TLS/SSL is determined automatically, so either true or false, it doesn't affect it
*
* By default it is true in android. If false then TLS is enabled.
*/
ssl?: boolean;
/**
* Optional list of bcc emails
* i.e: ["[email protected]", "[email protected]"]
*/
bcc?: Array<string>;
/**
* Optional path URIs of files that exist to the filesystem in the specified path, and want to be send as attachments
* i.e: [RNFS.DocumentDirectoryPath + "/sample_test.txt"]
*/
attachmentPaths?: Array<string>;
/**
* **Required if attachmentPaths are set, Only for android**
* The sending attachments filenames, will be renamed by these. It's important to set these, otherwise they are not always shown in the received email
* i.e: ["renamed_sample_test.txt"] or ["sample_test.txt"] etc
*/
attachmentNames?: Array<string>;
}
class SmtpMailer {
public static sendMail(options: SmtpOptions): Promise<string> {
return RNSmtpMailer.sendMail(options);
}
}
export default SmtpMailer;