ARCHIVE NOTICE
My website can still be found at industrialcuriosity.com, but I have not been posting on this blog as I've been primarily focused on therightstuff.medium.com - please head over there and take a look!
Saturday, 24 August 2019
simple-free-encryption-tool frontend now handles files
If your browser supports it, simple-free-encryption-tool can now encrypt and decrypt any local files you wish!
Friday, 23 August 2019
Handling emails with node.js and Mailparser
After sorting out mail forwarding and piping emails with postfix, I then needed to understand how to handle emails being POSTed to an API endpoint.
To parse an email with node.js, I recommend using Mailparser's simpleParser. I'm using express with bodyParser configured as follows:
To test, send the example email to the endpoint via curl:
curl --data-binary "@./example.eml" http://your-domain-name/api/email
or Postman (attach file to "binary").
And we're good to go!
To parse an email with node.js, I recommend using Mailparser's simpleParser. I'm using express with bodyParser configured as follows:
app.use(bodyParser.json({ limit : config.bodyLimit }));In your handler:
const express = require('express'); const router = express.Router(); const simpleParser = require('mailparser').simpleParser;or
import { Router } from 'express'; import { simpleParser } from 'mailparser';and then
api.post('/', (req, res) => { simpleParser(req) .then(parsed => { res.json(parsed); }) .catch(err => { res.json(500, err); }); });Mailparser is excellent, and documented, but the documentation assumes that we're familiar with the email format. Fortunately, oblac's example email exists for those of us who aren't!
To test, send the example email to the endpoint via curl:
curl --data-binary "@./example.eml" http://your-domain-name/api/email
or Postman (attach file to "binary").
And we're good to go!
Thursday, 22 August 2019
Mail forwarding and piping emails with Postfix for multiple domains
The past few weeks I've been learning about mail servers, and the biggest takeaway for me is that it's generally worth paying someone else to handle the headache. As usual, the obstacles to configuring a mail server correctly are primarily in the lack of useful documentation and examples, so I'm putting this down here in the hopes that it'll be helpful to like-minded constructively-lazy devs.
While I'm happily using mailgun for mail sending (after much frustration I threw in the towel trying to integrate DKIM packages with Postfix to get my outgoing emails secured) I was certain that I could at least have my mail server handle mail-forwarding for my multiple domains, and while that proved to be fairly straightforward I then tumbled down a rabbit-hole trying to get Postfix to pipe certain emails to a node.js script for processing.
You should be able to find your postfix logs at /var/log/mail.log. Good luck!
While I'm happily using mailgun for mail sending (after much frustration I threw in the towel trying to integrate DKIM packages with Postfix to get my outgoing emails secured) I was certain that I could at least have my mail server handle mail-forwarding for my multiple domains, and while that proved to be fairly straightforward I then tumbled down a rabbit-hole trying to get Postfix to pipe certain emails to a node.js script for processing.
- Here are the steps you'll need to take:
- Set up your A and MX records for your domain, the A record @ pointing to the IP address of the server you’re going to be receiving emails on and MX with the hostname @ and the value 10 mail.your-domain-name
If your mail server is not the same as your primary A record, simply create an additional A record mail pointing to the correct IP address. - sudo apt-get install postfix
Select "Internet Site" and enter your-domain-name (fully qualified) - sudo vi /etc/postfix/main.cf
- Add mail.your-domain-name to the list of mydestination values
- Append
virtual_alias_domains = hash:/etc/postfix/virtual_domains virtual_alias_maps = hash:/etc/postfix/virtual
to the end of the file
- sudo vi /etc/aliases
curl_email: "|curl --data-binary @- http://your-domain-name/email"
- sudo newaliases
- sudo vi /etc/postfix/virtual_domains
example.net #domain example.com #domain your-domain-name #domain
(the #domain fields suppress warnings) - sudo postmap /etc/postfix/virtual_domains
- sudo vi /etc/postfix/virtual
info@your-domain-name bob@gmail.com everyone@your-domain-name bob@gmail.com jim@gmail.com email_processor@your-domain-name curl_email@localhost @your-domain-name catchall@whereveryouwant.com ted@example.net jane@outlook.com
- sudo postmap /etc/postfix/virtual
- sudo /etc/init.d/postfix reload
You should be able to find your postfix logs at /var/log/mail.log. Good luck!
Monday, 5 August 2019
FreeVote: anonymous Q&A app
I can't believe something like this doesn't exist already! It's far from a polished product, but it's already pretty functional. Feel free to send me feedback, it'll help me prioritize the long list of improvements I've already come up with. This was inspired by my coworkers, every retrospective we all write down answers to sensitive questions "anonymously" on folded papers that one team member gathers and reviews... this way we can do it truly anonymously and all see the results.
FreeVote
FreeVote
Subscribe to:
Posts (Atom)
Labels
algorithms
(2)
art
(2)
automation
(8)
aws
(4)
azure
(2)
bamboo
(1)
banking
(2)
blockchain
(1)
books
(5)
c#
(7)
cloud
(4)
collaboration
(5)
comics
(3)
comments
(4)
communication
(6)
crypto
(1)
data ownership
(1)
database
(5)
deployment
(10)
design
(3)
design patterns
(2)
development
(32)
devops
(5)
documentation
(16)
dynamodb
(1)
encryption
(6)
formatting
(4)
git
(1)
golang
(1)
google
(1)
hiring
(1)
html5
(5)
iis
(1)
installation
(5)
integration
(2)
interfaces
(2)
java
(1)
javascript
(11)
lambda
(2)
linux
(5)
mysql
(1)
node.js
(7)
open source
(15)
plugins
(3)
privacy
(2)
processes
(2)
promotions
(1)
python
(4)
readability
(3)
recruitment
(1)
regex
(2)
reviews
(1)
security
(13)
self-publishing
(2)
shakespeare
(3)
sql server
(1)
tattoos
(2)
tools
(21)
user experience
(1)
version control
(3)
virtualization
(1)