|
18 | 18 | // AMD shim
|
19 | 19 | (function(root, factory) {
|
20 | 20 | if (typeof define === 'function' && define.amd) {
|
21 |
| - define(['../../mailcomposer/mailcomposer', './smtpClient/smtpClient'], factory); |
| 21 | + define(['../../mailcomposer/mailcomposer', '../../smtpclient/smtpclient'], factory); |
22 | 22 | } else {
|
23 |
| - root.firemail = factory(root.mailcomposer, root.smtpClient); |
| 23 | + root.firemail = factory(root.mailcomposer, root.smtpclient); |
24 | 24 | }
|
25 |
| -}(this, function(mailcomposer, smtpClient) { |
| 25 | +}(this, function(mailcomposer, smtpclient) { |
26 | 26 |
|
27 | 27 | "use strict";
|
28 | 28 |
|
|
49 | 49 | /**
|
50 | 50 | * SMTP client
|
51 | 51 | */
|
52 |
| - this._smtpClient = smtpClient(this.mail.smtp.host, this.mail.smtp.port, this.mail.smtp); |
| 52 | + this._smtpclient = smtpclient(this.mail.smtp.host, this.mail.smtp.port, this.mail.smtp); |
53 | 53 |
|
54 | 54 | // Setup SMTP events
|
55 |
| - this._smtpClient.onidle = this._smtpClientOnIdle.bind(this); |
56 |
| - this._smtpClient.onclose = this._smtpClientOnClose.bind(this); |
57 |
| - this._smtpClient.onerror = this._smtpClientOnError.bind(this); |
58 |
| - this._smtpClient.ondrain = this._smtpClientOnDrain.bind(this); |
59 |
| - this._smtpClient.onready = this._smtpClientOnReady.bind(this); |
60 |
| - this._smtpClient.ondone = this._smtpClientOnDone.bind(this); |
| 55 | + this._smtpclient.onidle = this._smtpclientOnIdle.bind(this); |
| 56 | + this._smtpclient.onclose = this._smtpclientOnClose.bind(this); |
| 57 | + this._smtpclient.onerror = this._smtpclientOnError.bind(this); |
| 58 | + this._smtpclient.ondrain = this._smtpclientOnDrain.bind(this); |
| 59 | + this._smtpclient.onready = this._smtpclientOnReady.bind(this); |
| 60 | + this._smtpclient.ondone = this._smtpclientOnDone.bind(this); |
61 | 61 |
|
62 | 62 | // Setup mail composer
|
63 | 63 |
|
|
71 | 71 | this._composer.onend = this._composerOnEnd.bind(this);
|
72 | 72 |
|
73 | 73 | // Initiate mail sending by connecting to SMTP
|
74 |
| - this._smtpClient.connect(); |
| 74 | + this._smtpclient.connect(); |
75 | 75 | }
|
76 | 76 |
|
77 | 77 | /**
|
78 | 78 | * Fired when SMTP client enters idled state (after successfull auth)
|
79 | 79 | * Setups the mail and transfers the envelope to SMTP
|
80 | 80 | */
|
81 |
| - Sendmail.prototype._smtpClientOnIdle = function(){ |
| 81 | + Sendmail.prototype._smtpclientOnIdle = function(){ |
82 | 82 | // Set default options
|
83 | 83 | ["subject", "from", "sender", "to", "cc", "bcc", "reply-to", "in-reply-to", "references"].forEach((function(key){
|
84 | 84 | if(key in this.mail){
|
|
114 | 114 | }).bind(this));
|
115 | 115 |
|
116 | 116 | // send envelope to smtp
|
117 |
| - this._smtpClient.useEnvelope(this._composer.getEnvelope()); |
| 117 | + this._smtpclient.useEnvelope(this._composer.getEnvelope()); |
118 | 118 | };
|
119 | 119 |
|
120 | 120 | /**
|
121 | 121 | * Fired when SMTP client enters Ready state (envelope has been set up and data can be sent)
|
122 | 122 | * Starts streaming by the mail composer
|
123 | 123 | */
|
124 |
| - Sendmail.prototype._smtpClientOnReady = function(){ |
| 124 | + Sendmail.prototype._smtpclientOnReady = function(){ |
125 | 125 | this._composer.stream();
|
126 | 126 | };
|
127 | 127 |
|
128 | 128 | /**
|
129 | 129 | * Fired when SMTP client emits ondrain event. Mail composer can resume streaming
|
130 | 130 | */
|
131 |
| - Sendmail.prototype._smtpClientOnDrain = function(){ |
| 131 | + Sendmail.prototype._smtpclientOnDrain = function(){ |
132 | 132 | this._composer.resume();
|
133 | 133 | };
|
134 | 134 |
|
|
137 | 137 | *
|
138 | 138 | * @param {Boolean} success If true, the mail was sent successfully
|
139 | 139 | */
|
140 |
| - Sendmail.prototype._smtpClientOnDone = function(success){ |
141 |
| - this._smtpClient.onidle = function(){}; // prevent sending the mail again |
142 |
| - this._smtpClient.quit(); // QUIT |
| 140 | + Sendmail.prototype._smtpclientOnDone = function(success){ |
| 141 | + this._smtpclient.onidle = function(){}; // prevent sending the mail again |
| 142 | + this._smtpclient.quit(); // QUIT |
143 | 143 | this._returned = true;
|
144 | 144 | this.callback(null, success);
|
145 | 145 | };
|
|
149 | 149 | *
|
150 | 150 | * @param {Error} err Error received
|
151 | 151 | */
|
152 |
| - Sendmail.prototype._smtpClientOnError = function(err){ |
| 152 | + Sendmail.prototype._smtpclientOnError = function(err){ |
153 | 153 | if(!this._returned){
|
154 | 154 | this._returned = true;
|
155 | 155 | this.callback(err);
|
|
161 | 161 | /**
|
162 | 162 | * Connection to the SMTP server has been closed
|
163 | 163 | */
|
164 |
| - Sendmail.prototype._smtpClientOnClose = function(){ |
| 164 | + Sendmail.prototype._smtpclientOnClose = function(){ |
165 | 165 | //console.log("Connection closed");
|
166 | 166 | };
|
167 | 167 |
|
|
173 | 173 | * @param {String} data Chunk to be sent to the SMTP server
|
174 | 174 | */
|
175 | 175 | Sendmail.prototype._composerOnData = function(chunk){
|
176 |
| - if(!this._smtpClient.send(chunk)){ |
| 176 | + if(!this._smtpclient.send(chunk)){ |
177 | 177 | this._composer.suspend();
|
178 | 178 | }
|
179 | 179 | };
|
|
182 | 182 | * Fired when mail cposer has emitted the entire message
|
183 | 183 | */
|
184 | 184 | Sendmail.prototype._composerOnEnd = function(){
|
185 |
| - this._smtpClient.end(); |
| 185 | + this._smtpclient.end(); |
186 | 186 | };
|
187 | 187 |
|
188 | 188 | return function(mail, callback){
|
|
0 commit comments