@@ -3,85 +3,127 @@ import 'package:freezed_annotation/freezed_annotation.dart';
3
3
import 'package:mailer/smtp_server.dart' ;
4
4
5
5
part 'provider.freezed.dart' ;
6
+
6
7
part 'provider.g.dart' ;
8
+
7
9
part 'provider.mapper.dart' ;
8
10
9
11
/// Mailer provider configuration.
10
- @Freezed (unionKey : 'type' , fallbackUnion: 'none' )
12
+ @Freezed (fallbackUnion: 'none' )
11
13
@MappableClass ()
12
14
interface class MailerProviderConfiguration
13
15
with MailerProviderConfigurationMappable , _$MailerProviderConfiguration {
14
16
const MailerProviderConfiguration ._();
15
17
16
- /// Default port for custom SMTP servers.
17
- static const _defaultSmtpPort = 587 ;
18
-
19
- /// Ignore bad certificates on custom SMTP server.
20
- static const _defaultSmtpIgnoreBadCertificate = false ;
21
-
22
- /// Use ssl on custom SMTP server.
23
- static const _defaultSmtpSsl = false ;
24
-
25
- /// Allow insecure communication on custom SMTP server.
26
- static const _defaultSmtpAllowInsecure = false ;
27
-
28
- /// Default port of papercut SMTP server.
29
- static const _defaultPapercutPort = 25 ;
30
-
31
- /// Default hostname of papercut SMTP server.
32
- static const _defaultPapercutHost = '127.0.0.1' ;
33
-
34
18
/// Disables mailer.
35
19
const factory MailerProviderConfiguration .none () =
36
20
_MailerProviderConfigurationNone ;
37
21
38
22
/// Smtp mailer.
39
23
const factory MailerProviderConfiguration .smtp ({
40
- required String host,
41
- @Default (MailerProviderConfiguration ._defaultSmtpPort) int port,
42
- @Default (MailerProviderConfiguration ._defaultSmtpIgnoreBadCertificate)
24
+ /// Host to use.
25
+ @Default ('localhost' ) //
26
+ String host,
27
+
28
+ /// Port to use.
29
+ @Default (587 ) //
30
+ int port,
31
+
32
+ /// Ignore bad server SSL certificate.
33
+ @Default (false ) //
43
34
bool ignoreBadCertificate,
44
- @Default (MailerProviderConfiguration ._defaultSmtpSsl) bool ssl,
45
- @Default (MailerProviderConfiguration ._defaultSmtpAllowInsecure)
35
+
36
+ /// Use SSL for communication with server.
37
+ @Default (false ) //
38
+ bool ssl,
39
+
40
+ /// Allow insecure communication with server.
41
+ @Default (false ) //
46
42
bool allowInsecure,
43
+
44
+ /// Username of mailing user.
47
45
String ? username,
46
+
47
+ /// Password of mailing user.
48
48
String ? password,
49
+
50
+ /// XOAuth2 of mailing user.
49
51
String ? xoauth2Token,
50
52
}) = _MailerProviderConfigurationSmtp ;
51
53
52
54
/// Gmail mailer provider.
53
55
const factory MailerProviderConfiguration .gmail (
54
- String username, String password) = _MailerProviderConfigurationGmail ;
56
+ /// Username of mailing user.
57
+ String username,
58
+
59
+ /// Password of mailing user.
60
+ String password,
61
+ ) = _MailerProviderConfigurationGmail ;
55
62
56
63
/// Outlook Hotmail mailer provider.
57
64
const factory MailerProviderConfiguration .hotmail (
58
- String username, String password) = _MailerProviderConfigurationHotmail ;
65
+ /// Username of mailing user.
66
+ String username,
67
+
68
+ /// Password of mailing user.
69
+ String password,
70
+ ) = _MailerProviderConfigurationHotmail ;
59
71
60
72
/// Mailgun mailer provider.
61
73
const factory MailerProviderConfiguration .mailgun (
62
- String username, String password) = _MailerProviderConfigurationMailgun ;
74
+ /// Username of mailing user.
75
+ String username,
76
+
77
+ /// Password of mailing user.
78
+ String password,
79
+ ) = _MailerProviderConfigurationMailgun ;
63
80
64
81
/// Papercut mailer provider.
65
- const factory MailerProviderConfiguration .papercut ([
66
- @Default (MailerProviderConfiguration ._defaultPapercutHost) String host,
67
- @Default (MailerProviderConfiguration ._defaultPapercutPort) int port,
68
- ]) = _MailerProviderConfigurationPapercut ;
82
+ const factory MailerProviderConfiguration .papercut ({
83
+ /// Host to use.
84
+ @Default ('localhost' ) //
85
+ String host,
86
+
87
+ /// Port to use.
88
+ @Default (25 ) //
89
+ int port,
90
+ }) = _MailerProviderConfigurationPapercut ;
69
91
70
92
/// Tencent QQ mailer provider.
71
93
const factory MailerProviderConfiguration .qq (
72
- String username, String password) = _MailerProviderConfigurationQQ ;
94
+ /// Username of mailing user.
95
+ String username,
96
+
97
+ /// Password of mailing user.
98
+ String password,
99
+ ) = _MailerProviderConfigurationQQ ;
73
100
74
101
/// Yahoo mailer provider.
75
102
const factory MailerProviderConfiguration .yahoo (
76
- String username, String password) = _MailerProviderConfigurationYahoo ;
103
+ /// Username of mailing user.
104
+ String username,
105
+
106
+ /// Password of mailing user.
107
+ String password,
108
+ ) = _MailerProviderConfigurationYahoo ;
77
109
78
110
/// Yandex mailer provider
79
111
const factory MailerProviderConfiguration .yandex (
80
- String username, String password) = _MailerProviderConfigurationYandex ;
112
+ /// Username of mailing user.
113
+ String username,
114
+
115
+ /// Password of mailing user.
116
+ String password,
117
+ ) = _MailerProviderConfigurationYandex ;
81
118
82
119
/// Zoho mailer provider.
83
120
const factory MailerProviderConfiguration .zoho (
84
- String username, String password) = _MailerProviderConfigurationZoho ;
121
+ /// Username of mailing user.
122
+ String username,
123
+
124
+ /// Password of mailing user.
125
+ String password,
126
+ ) = _MailerProviderConfigurationZoho ;
85
127
86
128
/// Get mailer server endpoint based on this config.
87
129
SmtpServer ? get smtpServer => switch (this ) {
0 commit comments