Send and Receive E-mails in Development
Cozy apps let users share documents from cozy to cozy.
Meet Alice and Bob. Alice wants to share a folder with Bob. Alice clicks on the share button and fills in the email input with Bob’s email address. Bob receives an email with a « Accept the sharing » button. Bob clicks on that button and is redirected to Alice’s cozy to enter his own cozy url to link both cozys. Bob sees Alice’s shared folder in his own cozy.
🤔 But how could we do this scenario on development environment?
With the docker image¶
If you develop with the cozy-app-dev docker image, MailHog is running inside it to catch emails.
If cozy-stack has to send an email, MailHog catches it and exposes it on its web interface on http://cozy.tools:8025/.
With the binary cozy-stack¶
If you develop with the cozy-stack CLI, you have to run MailHog on your computer and tell cozy-stack serve
where to find the mail server with some options:
./cozy-stack serve --appdir drive:../cozy-drive/build,settings:../cozy-settings/build --mail-disable-tls --mail-port 1025
This commands assumes you git clone
cozy-drive and cozy-settings in the same folder than you git clone
cozy-stack.
Then simply run MailHog
and open http://cozy.tools:8025/.
Retrieve sent emails¶
With MailHog, every email sent by cozy-stack is caught. That means the email address does not have to be a real one, ie. bob@cozy
, bob@cozy.tools
are perfectly fine. It could be a real one, but the email will not reach the real recipient’s inbox, say contact@cozycloud.cc
.