Files
herolib/lib/clients/sendgrid
Mahmoud-Emad f789564f51 feat: Add encoderhero and heroscript_dumps/loads
- Add encoderhero import to multiple modules
- Implement heroscript_dumps and heroscript_loads functions
- Update several methods to use `if mut` for cleaner optionals
- Rename rclone globals for clarity
2025-10-13 21:49:19 +03:00
..
2024-12-25 20:45:21 +01:00
2024-12-25 09:23:31 +01:00
2024-12-25 09:23:31 +01:00
...
2025-10-13 08:30:42 +04:00

SendGrid Client

The SendGrid module allows you to use SendGrid services.

About SendGrid

SendGrid is a cloud-based email delivery and communication platform that empowers businesses and developers to send transactional and marketing emails to their customers or users. It offers tools and APIs to manage email campaigns, monitor delivery, and gather analytics on recipient engagement.

Requirements

To utilize this module, you will need:

  • A SendGrid API key: Create a SendGrid account and acquire your API key here.

Usage

To send an email using the SendGrid module, follow these steps:

1. Set Up a new email

In your V code, set up the email as shown below:

email := sendgrid.new_email(
  ['target_email@example.com', 'target_email2@example.com'],
  'source_email@example.com',
  'Email Title', 'Email content; can include HTML')

2. Execute the program

You can execute the program using the following command:

v run sendgrid/example/main.v -t "YOUR_API_TOKEN"

You can provide the API key using the -t command-line argument, or you can export the API key using the following command:

export SENDGRID_AUTH_TOKEN="YOUR_API_TOKEN"

Additionally, you can enable debug mode by passing the -d flag:

v run sendgrid/example/main.v -d -t "YOUR_API_TOKEN"

Advanced

We provide some useful structs and methods in email and personalization that you can leverage to tailor the emails according to your specific requirements. You can check the SendGrid API reference here