Update SMTP setup instructions

Add smtp port and tls options
Use /user/ path for shorthand sharing link
This commit is contained in:
Tankred Hase 2016-06-02 09:24:57 +02:00
parent 111581bb78
commit 1c6696e7a4
7 changed files with 21 additions and 13 deletions

View File

@ -14,4 +14,4 @@ notifications:
services:
- mongodb
env:
- MONGO_URI=127.0.0.1:27017/test_db MONGO_USER=travis MONGO_PASS=test SMTP_HOST=127.0.0.1 SMTP_USER=smtp_user SMTP_PASS=smtp_pass SENDER_NAME=Travis SENDER_EMAIL=travis@mailvelope.com
- MONGO_URI=127.0.0.1:27017/test_db MONGO_USER=travis MONGO_PASS=test SMTP_HOST=127.0.0.1 SMTP_PORT=465 SMTP_TLS=true SMTP_USER=smtp_user SMTP_PASS=smtp_pass SENDER_NAME=Travis SENDER_EMAIL=travis@mailvelope.com

View File

@ -122,7 +122,7 @@ GET /api/v1/key?email=user@example.com
#### By email address (shorthand link for sharing)
```
GET /user@example.com
GET /user/user@example.com
```
### Request key removal
@ -194,7 +194,7 @@ db.createUser({ user:"keyserver-user", pwd:"trfepCpjhVrqgpXFWsEF", roles:[{ role
## Setup SMTP user
The key server uses [nodemailer](https://nodemailer.com) to send out emails upon public key upload to verify email address ownership. To test this feature locally, open the `credentials.json` file and change the `user@gmail.com` to your Gmail test account. Be sure that `smtp.user` and `sender.email` match. Otherwise the Gmail SMTP server will block any emails you try to send. Also, be sure to enable the "less secure apps" in the Gmail security settings. You can read how to do this in the [Nodemailer documentation](https://nodemailer.com/using-gmail/).
The key server uses [nodemailer](https://nodemailer.com) to send out emails upon public key upload to verify email address ownership. To test this feature locally, open the `credentials.json` file and change the `smtp.user` and `smtp.pass` attributes to your Gmail test account. Make sure that `smtp.user` and `sender.email` match. Otherwise the Gmail SMTP server will block any emails you try to send. Also, make sure to enable `Allow less secure apps` in the [Gmail security settings](https://myaccount.google.com/security#connectedapps). You can read more on this in the [Nodemailer documentation](https://nodemailer.com/using-gmail/).
For production you should use a service like [Amazon SES](https://aws.amazon.com/ses/), [Mailgun](https://www.mailgun.com/) or [Sendgrid](https://sendgrid.com/solutions/transactional-email/). Nodemailer supports all of these out of the box.
@ -221,9 +221,11 @@ The `credentials.json` file can be used to configure a local development install
* MONGO_USER=db_user
* MONGO_PASS=db_password
* SMTP_HOST=127.0.0.1
* SMTP_PORT=465
* SMTP_TLS=true
* SMTP_USER=smtp_user
* SMTP_PASS=smtp_pass
* SENDER_NAME=Sender
* SENDER_NAME="OpenPGP Key Server"
* SENDER_EMAIL=noreply@example.com

View File

@ -6,6 +6,8 @@
},
"smtp": {
"host": "smtp.gmail.com",
"port": "465",
"tls": "true",
"user": "user@gmail.com",
"pass": "password"
},

View File

@ -63,7 +63,7 @@ router.get('/api/v1/verify', function *() { // ?keyid=keyid&nonce=nonce
router.get('/api/v1/verifyRemove', function *() { // ?keyid=keyid&nonce=nonce
yield rest.verifyRemove(this);
});
router.get('/:email', function *() { // shorthand link for sharing
router.get('/user/:email', function *() { // shorthand link for sharing
yield rest.share(this);
});
@ -103,6 +103,8 @@ function injectDependencies() {
email = new Email(nodemailer);
email.init({
host: process.env.SMTP_HOST || credentials.smtp.host,
port: process.env.SMTP_PORT || credentials.smtp.port,
secure: (process.env.SMTP_TLS || credentials.smtp.tls) === 'true',
auth: {
user: process.env.SMTP_USER || credentials.smtp.user,
pass: process.env.SMTP_PASS || credentials.smtp.pass

View File

@ -47,8 +47,8 @@ class Email {
host: options.host,
port: options.port || 465,
auth: options.auth,
secure: options.secure || true,
requireTLS: options.requireTLS || true
secure: (options.secure !== undefined) ? options.secure : true,
requireTLS: (options.secure !== undefined) ? options.secure : true
});
this._sender = options.sender;
}

View File

@ -200,7 +200,7 @@ describe('Koa App (HTTP Server) Integration Tests', function() {
});
});
describe('GET /:email (sharing link)', () => {
describe('GET /user/:email (sharing link)', () => {
beforeEach(done => {
request(app.listen())
.post('/api/v1/key')
@ -212,7 +212,7 @@ describe('Koa App (HTTP Server) Integration Tests', function() {
describe('Not yet verified', () => {
it('should return 404', done => {
request(app.listen())
.get('/' + primaryEmail)
.get('/user/' + primaryEmail)
.expect(404)
.end(done);
});
@ -228,28 +228,28 @@ describe('Koa App (HTTP Server) Integration Tests', function() {
it('should return 200 for correct email address', done => {
request(app.listen())
.get('/' + primaryEmail)
.get('/user/' + primaryEmail)
.expect(200, publicKeyArmored)
.end(done);
});
it('should return 400 for invalid email', done => {
request(app.listen())
.get('/a@bco')
.get('/user/a@bco')
.expect(400)
.end(done);
});
it('should return 404 for unkown email', done => {
request(app.listen())
.get('/a@b.co')
.get('/user/a@b.co')
.expect(404)
.end(done);
});
it('should return 404 for missing email', done => {
request(app.listen())
.get('/')
.get('/user/')
.expect(404)
.end(done);
});

View File

@ -37,6 +37,8 @@ describe('Email Integration Tests', function() {
email = new Email(nodemailer);
email.init({
host: process.env.SMTP_HOST || credentials.smtp.host,
port: process.env.SMTP_PORT || credentials.smtp.port,
secure: (process.env.SMTP_TLS || credentials.smtp.tls) === 'true',
auth: {
user: process.env.SMTP_USER || credentials.smtp.user,
pass: process.env.SMTP_PASS || credentials.smtp.pass