send mail from one user to another

This commit is contained in:
Girish Ramakrishnan 2016-06-24 00:29:34 -05:00
parent ae1cc03ee4
commit 69fc2408b4
3 changed files with 35 additions and 22 deletions

View File

@ -33,6 +33,10 @@ function Cloudron(box) {
};
}
Cloudron.prototype.fqdn = function () {
return this._box.domain;
};
Cloudron.prototype.adminFqdn = function () {
return 'my' + (this._isCustomDomain ? '.' : '-') + this._box.domain;
};
@ -548,24 +552,6 @@ Cloudron.prototype.setDnsConfig = function (dnsConfig) {
common.verifyResponse2xx(res, 'Could not set dns config');
};
Cloudron.prototype.checkMail = function (owner, callback) {
var imap = new ImapProbe({
user: owner.username,
password: owner.password,
host: this._adminFqdn,
port: 993, // imap port
tls: true,
tlsOptions: { rejectUnauthorized: false },
readOnly: true
});
imap.probe({
subject: new RegExp('^Hi from e2e test$'),
to: new RegExp(owner.username + '@' + this._box.domain),
body: /The release depends on you/
}, callback);
};
Cloudron.prototype.saveSieveScript = function (owner, callback) {
var authString = 'AUTHENTICATE "PLAIN" "' + new Buffer('\0' + owner.username + '\0' + owner.password).toString('base64') + '"';
var data = '';
@ -641,9 +627,28 @@ Cloudron.prototype.sendMail = function (owner, to, callback) {
var mailOptions = {
from: owner.username + '@'+ this._box.domain,
to: to,
subject: 'Hello from e2e test',
text: 'The release depends on you'
subject: 'Hi from e2e test - ' + this._box.domain,
text: 'This release depends on you'
};
transport.sendMail(mailOptions, callback);
};
Cloudron.prototype.checkMail = function (owner, callback) {
var imap = new ImapProbe({
user: owner.username,
password: owner.password,
host: this._adminFqdn,
port: 993, // imap port
tls: true,
tlsOptions: { rejectUnauthorized: false },
readOnly: true
});
imap.probe({
subject: new RegExp('^Hi from e2e test - ' + this._box.domain + '$'),
to: new RegExp(owner.username + '@' + this._box.domain),
body: /This release depends on you/
}, callback);
};

View File

@ -83,8 +83,8 @@ describe('Cloudron backup testing', function () {
it('sent mail successfully', function (done) {
imap.probe({
subject: new RegExp('^Hello from e2e test$'),
body: /The release depends on you/
subject: new RegExp('^Hi from e2e test$'),
body: /This release depends on you/
}, done);
});

View File

@ -84,6 +84,14 @@ describe('Cloudron user creation testing', function () {
cloudron.getOauthToken({ username: 'newuser', password: 'Strong?132' });
});
it('can send mail from one user to another', function (done) {
cloudron.sendMail(owner, 'newuser@' + cloudron.fqdn(), done);
});
it('can receive mail', function (done) {
cloudron.checkMail({ username: 'newuser', password: 'Strong?132' }, done);
});
it('can delete the cloudron', function () {
appStore.deleteCloudron(box);
});