# Default Configuration

ShipWithDjango provides flexible email configuration options, allowing you to choose between using a standard SMTP server or SendGrid for sending emails. The main settings for your email provider are managed through environment variables, ensuring secure and centralized management. However, you can control certain behaviors directly within the `CONFIG/email.py` file.

Here’s a breakdown of the default configuration and how you can customize it:

```python
from shipwithdjango.secrets import secret_manager

# This variable is used to determine which email provider to use
# This can be either normal SMTP or SendGrid.
# If you want to use SendGrid, set this to 'sendgrid' and set the SENDGRID_API_KEY variable.
EMAIL_PROVIDER = 'smtp' # 'smtp' or 'sendgrid'

# If this variable is set to True, sending emails will be done using the task queue (Huey) instead of the main thread.
# This is useful for sending emails asynchronously. If you set this to True, make sure to run the task queue worker.
# If you set this to False, emails will be sent synchronously and the main thread will be blocked until the email is sent.
EMAIL_USE_TASK_QUEUE = True

EMAIL_HOST = secret_manager.get_secret('EMAIL_HOST')
EMAIL_PORT = secret_manager.get_secret('EMAIL_PORT')
EMAIL_HOST_USER_NAME = secret_manager.get_secret('EMAIL_HOST_USER_NAME')
EMAIL_HOST_USER = secret_manager.get_secret('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = secret_manager.get_secret('EMAIL_HOST_PASSWORD')
EMAIL_USE_TLS = secret_manager.get_secret('EMAIL_USE_TLS')
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER

SENDGRID_API_KEY = secret_manager.get_secret('SENDGRID_API_KEY')
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.shipwithdjango.com/emailing/default-configuration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
