mirror of
https://github.com/documenso/documenso.git
synced 2025-11-12 07:43:16 +10:00
setup STMP from .env
This commit is contained in:
14
.env.example
14
.env.example
@ -13,12 +13,20 @@ NEXT_PUBLIC_WEBAPP_URL='http://localhost:3000'
|
|||||||
NEXTAUTH_SECRET='lorem ipsum sit dolor random string for encryption this could literally be anything'
|
NEXTAUTH_SECRET='lorem ipsum sit dolor random string for encryption this could literally be anything'
|
||||||
NEXTAUTH_URL='http://localhost:3000'
|
NEXTAUTH_URL='http://localhost:3000'
|
||||||
|
|
||||||
# MAIL
|
# MAIL (NODEMAILER)
|
||||||
|
# SENDGRID
|
||||||
# Get a Sendgrid Api key here: https://signup.sendgrid.com
|
# Get a Sendgrid Api key here: https://signup.sendgrid.com
|
||||||
# You can also configure you own SMTP server using Nodemailer in sendMailts. (currently not possible via config)
|
|
||||||
SENDGRID_API_KEY=''
|
SENDGRID_API_KEY=''
|
||||||
|
|
||||||
|
# SMTP
|
||||||
|
# Set SMTP credentials to use SMTP instead of the Sendgrid API.
|
||||||
|
SMTP_MAIL_HOST=''
|
||||||
|
SMTP_MAIL_PORT=''
|
||||||
|
SMTP_MAIL_USER=''
|
||||||
|
SMTP_MAIL_PASSWORD=''
|
||||||
|
|
||||||
# Sender for signing requests and completion mails.
|
# Sender for signing requests and completion mails.
|
||||||
MAIL_FROM=''
|
MAIL_FROM='documenso@localhost.com'
|
||||||
|
|
||||||
#FEATURE FLAGS
|
#FEATURE FLAGS
|
||||||
# Allow users to register via the /signup page. Otherwise they will be redirect to the home page.
|
# Allow users to register via the /signup page. Otherwise they will be redirect to the home page.
|
||||||
|
|||||||
30
README.md
30
README.md
@ -57,6 +57,7 @@
|
|||||||
Signing documents digitally is fast, easy and should be best practice for every document signed worldwide. This is technically quite easy today, but it also introduces a new party to every signature: The signing tool providers. While this is not a problem in itself, it should make us think about how we want these providers of trust to work. Documenso aims to be the world's most trusted document signing tool. This trust is built by empowering you to self-host Documenso and review how it works under the hood. Join us in creating the next generation of open trust infrastructure.
|
Signing documents digitally is fast, easy and should be best practice for every document signed worldwide. This is technically quite easy today, but it also introduces a new party to every signature: The signing tool providers. While this is not a problem in itself, it should make us think about how we want these providers of trust to work. Documenso aims to be the world's most trusted document signing tool. This trust is built by empowering you to self-host Documenso and review how it works under the hood. Join us in creating the next generation of open trust infrastructure.
|
||||||
|
|
||||||
## Community and Next Steps 🎯
|
## Community and Next Steps 🎯
|
||||||
|
|
||||||
The current project goal is to <b>[release a production ready version](https://github.com/documenso/documenso/milestone/1)</b> for self-hosting as soon as possible. If you want to help making that happen you can:
|
The current project goal is to <b>[release a production ready version](https://github.com/documenso/documenso/milestone/1)</b> for self-hosting as soon as possible. If you want to help making that happen you can:
|
||||||
|
|
||||||
- Check out the first source code release in this repository and test it
|
- Check out the first source code release in this repository and test it
|
||||||
@ -67,6 +68,7 @@ The current project goal is to <b>[release a production ready version](https://g
|
|||||||
- Fix or create [issues](https://github.com/documenso/documenso/issues), that are needed for the first production release
|
- Fix or create [issues](https://github.com/documenso/documenso/issues), that are needed for the first production release
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
- To contribute please see our [contribution guide](https://github.com/documenso/documenso/blob/main/CONTRIBUTING.md).
|
- To contribute please see our [contribution guide](https://github.com/documenso/documenso/blob/main/CONTRIBUTING.md).
|
||||||
|
|
||||||
## Tools
|
## Tools
|
||||||
@ -102,35 +104,37 @@ To run Documenso locally you need
|
|||||||
Follow these steps to setup documenso on you local machnine:
|
Follow these steps to setup documenso on you local machnine:
|
||||||
|
|
||||||
- [Clone the repository](https://help.github.com/articles/cloning-a-repository/) it to your local device.
|
- [Clone the repository](https://help.github.com/articles/cloning-a-repository/) it to your local device.
|
||||||
```sh
|
```sh
|
||||||
git clone https://github.com/documenso/documenso
|
git clone https://github.com/documenso/documenso
|
||||||
```
|
```
|
||||||
- Run <code>npm i</code> in root directory
|
- Run <code>npm i</code> in root directory
|
||||||
- Rename .env.example to .env
|
- Rename <code>.env.example</code> to <code>.env</code>
|
||||||
- Set DATABASE_URL value in .env file
|
- Set DATABASE_URL value in .env file
|
||||||
- You can use the provided test database url (may be wiped at any point)
|
- You can use the provided test database url (may be wiped at any point)
|
||||||
- Or setup a local postgres sql instance (recommened)
|
- Or setup a local postgres sql instance (recommened)
|
||||||
- Create the database scheme by running <code>db-migrate:dev</code>
|
- Create the database scheme by running <code>db-migrate:dev</code>
|
||||||
- Set SENDGRID_API_KEY value in .env file
|
- Setup your mail provider
|
||||||
- You need SendGrid account, which you can create [here](https://signup.sendgrid.com/).
|
- Set <code>SENDGRID_API_KEY</code> value in .env file
|
||||||
- Documenso uses [Nodemailer](https://nodemailer.com/about/) so you can easily use your own smtp server
|
- You need a SendGrid account, which you can create [here](https://signup.sendgrid.com/).
|
||||||
|
- Documenso uses [Nodemailer](https://nodemailer.com/about/) so you can easily use your own SMTP server by setting the <code>SMTP\_\* varibles</code> in your .env
|
||||||
- Run <code>npm run dev</code> root directory to start
|
- Run <code>npm run dev</code> root directory to start
|
||||||
- Register a new user at http://localhost:3000/signup
|
- Register a new user at http://localhost:3000/signup
|
||||||
- Optional: Seed the database using <code>npm run db-seed</code> to create a test user and document
|
|
||||||
- Optional: Upload and sign <code>apps\web\ressources\example.pdf</code> manually to test your setup
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
- Optional: Seed the database using <code>npm run db-seed</code> to create a test user and document
|
||||||
|
- Optional: Upload and sign <code>apps\web\ressources\example.pdf</code> manually to test your setup
|
||||||
|
|
||||||
- Optional: Create your own signing certificate
|
- Optional: Create your own signing certificate
|
||||||
- A demo certificate is provided in /app/web/ressources/certificate.p12
|
- A demo certificate is provided in /app/web/ressources/certificate.p12
|
||||||
- To generate you own using these steps and a linux Terminal or Windows Linux Subsystem see **Create your own signging certificate**.
|
- To generate you own using these steps and a linux Terminal or Windows Linux Subsystem see **Create your own signging certificate**.
|
||||||
|
|
||||||
## Updating
|
## Updating
|
||||||
|
|
||||||
- If you pull the newest version from main, using <code>git pull</code>, it may be neccessary to regenerate your database client
|
- If you pull the newest version from main, using <code>git pull</code>, it may be neccessary to regenerate your database client
|
||||||
- You can do this by running the generate command in /packages/prisma:
|
- You can do this by running the generate command in /packages/prisma:
|
||||||
```sh
|
```sh
|
||||||
npx prisma generate
|
npx prisma generate
|
||||||
```
|
```
|
||||||
- This is not neccessary on first clone
|
- This is not neccessary on first clone
|
||||||
|
|
||||||
# Creating your own signging certificate
|
# Creating your own signging certificate
|
||||||
@ -144,7 +148,7 @@ For the digital signature of you documents you need a signign certificate in .p1
|
|||||||
<code>openssl req -new -x509 -key private.key -out certificate.crt -days 365</code> \
|
<code>openssl req -new -x509 -key private.key -out certificate.crt -days 365</code> \
|
||||||
This will prompt you to enter some information, such as the Common Name (CN) for the certificate. Make sure you enter the correct information. The -days parameter sets the number of days for which the certificate is valid.
|
This will prompt you to enter some information, such as the Common Name (CN) for the certificate. Make sure you enter the correct information. The -days parameter sets the number of days for which the certificate is valid.
|
||||||
3. Combine the private key and the self-signed certificate to create the p12 certificate. You can run the following command to do this: \
|
3. Combine the private key and the self-signed certificate to create the p12 certificate. You can run the following command to do this: \
|
||||||
<code>openssl pkcs12 -export -out certificate.p12 -inkey private.key -in certificate.crt</code>
|
<code>openssl pkcs12 -export -out certificate.p12 -inkey private.key -in certificate.crt</code>
|
||||||
4. You will be prompted to enter a password for the p12 file. Choose a strong password and remember it, as you will need it to use the certificate (**can be empty for dev certificates**)
|
4. You will be prompted to enter a password for the p12 file. Choose a strong password and remember it, as you will need it to use the certificate (**can be empty for dev certificates**)
|
||||||
5. Place the certificate <code>/apps/web/ressource/certificate.p12</code>
|
5. Place the certificate <code>/apps/web/ressource/certificate.p12</code>
|
||||||
|
|
||||||
|
|||||||
@ -11,14 +11,29 @@ export const sendMail = async (
|
|||||||
content: string | Buffer;
|
content: string | Buffer;
|
||||||
}[] = []
|
}[] = []
|
||||||
) => {
|
) => {
|
||||||
if (!process.env.SENDGRID_API_KEY)
|
let transport;
|
||||||
throw new Error("Sendgrid API Key not set.");
|
if (process.env.SENDGRID_API_KEY)
|
||||||
|
transport = nodemailer.createTransport(
|
||||||
|
nodemailerSendgrid({
|
||||||
|
apiKey: process.env.SENDGRID_API_KEY || "",
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
if (process.env.SMTP_MAIL_HOST)
|
||||||
|
transport = nodemailer.createTransport({
|
||||||
|
host: process.env.SMTP_MAIL_HOST || "",
|
||||||
|
port: Number(process.env.SMTP_MAIL_PORT) || 587,
|
||||||
|
auth: {
|
||||||
|
user: process.env.SMTP_MAIL_USER || "",
|
||||||
|
pass: process.env.SMTP_MAIL_PASSWORD || "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!transport)
|
||||||
|
throw new Error(
|
||||||
|
"No valid transport for NodeMailer found. Probably Sendgrid API Key nor SMTP Mail host was set."
|
||||||
|
);
|
||||||
|
|
||||||
const transport = await nodemailer.createTransport(
|
|
||||||
nodemailerSendgrid({
|
|
||||||
apiKey: process.env.SENDGRID_API_KEY || "",
|
|
||||||
})
|
|
||||||
);
|
|
||||||
await transport
|
await transport
|
||||||
.sendMail({
|
.sendMail({
|
||||||
from: process.env.MAIL_FROM,
|
from: process.env.MAIL_FROM,
|
||||||
|
|||||||
Reference in New Issue
Block a user