Documentation
¶
Overview ¶
Package notification provides utilities for creating and sending email notifications through the RapidMail API. It includes functions for packaging HTML content into ZIP archives and sending email campaigns to recipients.
Features:
- Create ZIP archives from HTML files for email content
- Send email campaigns through RapidMail API
- Support for scheduled email delivery
- Base64 encoding of email content
- Recipient list management
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RapidMailCreateContentFromFile ¶
RapidMailCreateContentFromFile prepares HTML email content for RapidMail. This function creates a ZIP archive from an HTML file and encodes it in base64, which is the format required by the RapidMail API.
Parameters:
- htmlFilePath: Path to the HTML file containing the email content
Returns:
- string: Base64-encoded ZIP content
- error: If any step in the process fails
The function:
- Creates a ZIP file containing the HTML file
- Reads the ZIP file content
- Encodes the content in base64
- Returns the encoded string
func RapidMailSend ¶
func RapidMailSend(apiUser, apiPass, subject string, recipients []map[string]interface{}, htmlFilePath string) error
RapidMailSend sends an email campaign through the RapidMail API. This function creates and schedules an email campaign with the provided content and recipient list.
Parameters:
- apiUser: RapidMail API username
- apiPass: RapidMail API password
- subject: Email subject line
- recipients: List of recipient maps (each should contain "email" and optionally other fields)
- htmlFilePath: Path to the HTML file containing the email content
Returns:
- error: If any step in the process fails
The function:
- Prepares the email content by creating a ZIP and encoding it
- Creates a payload with campaign details and content
- Makes an authenticated POST request to the RapidMail API
- Logs the API response
Example recipient format:
[]map[string]interface{}{
{"email": "recipient1@example.com", "firstname": "John", "lastname": "Doe"},
{"email": "recipient2@example.com", "firstname": "Jane", "lastname": "Smith"},
}
Types ¶
This section is empty.