@@ -27,6 +27,31 @@ else {
27
27
} ) ;
28
28
}
29
29
30
+ /**
31
+ *
32
+ * @returns {string } email and company name
33
+ */
34
+ function getPluginConfig ( ) {
35
+ let email = null ;
36
+ let company = null ;
37
+ const pluginList = plugins . getPlugins ( true ) ;
38
+ if ( pluginList . indexOf ( 'white-labeling' ) > - 1 ) {
39
+ try {
40
+ const pluginsConfig = plugins . getConfig ( "white-labeling" ) ;
41
+ const { emailFrom, emailCompany} = pluginsConfig ;
42
+ email = emailFrom && emailFrom . length > 0 ? emailFrom : null ;
43
+ company = emailCompany && emailCompany . length > 0 ? emailCompany : null ;
44
+ if ( email && email . length && company && company . length ) {
45
+ return company + " <" + email + ">" ;
46
+ }
47
+ }
48
+ catch ( error ) {
49
+ console . log ( 'Error getting plugins config' , error ) ;
50
+ }
51
+ }
52
+ return null ;
53
+ }
54
+
30
55
/*
31
56
Use the below transport to send mails through Gmail
32
57
63
88
* @param {function } callback - function to call when its done
64
89
**/
65
90
mail . sendMail = function ( message , callback ) {
66
- message . from = config . mail && config . mail . strings && config . mail . strings . from || message . from || "Countly" ;
91
+ const whiteLabelingConfig = getPluginConfig ( ) ;
92
+ message . from = whiteLabelingConfig || config . mail && config . mail . strings && config . mail . strings . from || message . from || "Countly" ;
67
93
mail . smtpTransport . sendMail ( message , function ( error ) {
68
94
if ( error ) {
69
95
console . log ( 'Error sending email' ) ;
@@ -83,9 +109,10 @@ mail.sendMail = function(message, callback) {
83
109
* @param {function } callback - function to call when its done
84
110
**/
85
111
mail . sendMessage = function ( to , subject , message , callback ) {
112
+ const whiteLabelingConfig = getPluginConfig ( ) ;
86
113
mail . sendMail ( {
87
114
to : to ,
88
- from : config . mail && config . mail . strings && config . mail . strings . from || "Countly" ,
115
+ from : whiteLabelingConfig || config . mail && config . mail . strings && config . mail . strings . from || "Countly" ,
89
116
subject : subject || "" ,
90
117
html : message || ""
91
118
} , callback ) ;
0 commit comments