fix: update to AhaSend API v1 key
- Switch from API v2 to API v1 key - Simplify payload format for v1 API - Update documentation with domain verification requirement - API Key v1: pxZ2d30PIqTl6Uj7p6g3o0uez2AacMaOstKCTcj9MTIrNEBvhikgvyAARUTvXAcA Note: Domain beachlitter.ie likely needs verification in AhaSend dashboard
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
# AhaSend Email Integration Status
|
||||
|
||||
## Current Status: ⚠️ Configuration Issue
|
||||
## Current Status: ⚠️ Domain Verification Required
|
||||
|
||||
The notification system has been successfully implemented with AhaSend integration, but the API is currently returning "invalid credentials" errors.
|
||||
The notification system has been successfully implemented with AhaSend integration, but the API is returning "invalid credentials" errors. This is likely because the sending domain needs to be verified.
|
||||
|
||||
## Configuration
|
||||
|
||||
### Credentials (Configured)
|
||||
- **Account ID**: `8a14f9a5-6e6d-47c9-b5d6-a687265b36a3`
|
||||
- **Secret Key**: `aha-sk-A0c9WOA8cs3RpvkAGwHOP9o6pHx-gLTUki1gSWVeC_6kd86-Npn077zta-rvg9oo`
|
||||
- **API Endpoint**: `https://api.ahasend.com/v1/email`
|
||||
- **API Key v1**: `pxZ2d30PIqTl6Uj7p6g3o0uez2AacMaOstKCTcj9MTIrNEBvhikgvyAARUTvXAcA`
|
||||
- **API Endpoint**: `https://api.ahasend.com/v1/messages`
|
||||
|
||||
### Environment Variables (`.env`)
|
||||
```env
|
||||
@@ -37,12 +37,31 @@ HTTP Status: `403 Forbidden`
|
||||
4. ✅ Verified payload format matches API expectations
|
||||
5. ✅ Tested different endpoint paths
|
||||
|
||||
## Possible Causes
|
||||
## Most Likely Cause: Domain Verification
|
||||
|
||||
1. **API Key Not Activated**: The secret key may need to be activated in the AhaSend dashboard
|
||||
2. **Domain Verification Required**: The sending domain (`beachlitter.ie`) may need to be verified
|
||||
3. **Account Status**: The account may need additional setup or verification
|
||||
4. **API Documentation**: The API format may differ from what we're using
|
||||
**The sending domain `beachlitter.ie` needs to be verified in AhaSend before emails can be sent.**
|
||||
|
||||
### How to Verify Domain
|
||||
|
||||
1. Go to https://dash.ahasend.com/
|
||||
2. Navigate to **Domains** section
|
||||
3. Click **"Add Domain"**
|
||||
4. Enter `beachlitter.ie`
|
||||
5. Add the required DNS records (SPF, DKIM, etc.)
|
||||
6. Wait for verification (usually a few minutes)
|
||||
|
||||
### Alternative: Use a Verified Domain
|
||||
|
||||
If you don't own `beachlitter.ie`, you can:
|
||||
1. Use a domain you own and have access to DNS
|
||||
2. Or use a test email like `noreply@yourdomain.com`
|
||||
3. Update `FROM_EMAIL` in `.env` to match
|
||||
|
||||
## Other Possible Causes
|
||||
|
||||
1. **API Key Not Activated**: The API key may need time to activate
|
||||
2. **Account Status**: The account may need additional setup
|
||||
3. **API Format**: The payload format may need adjustment
|
||||
|
||||
## Next Steps
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import axios from 'axios';
|
||||
|
||||
// AhaSend API configuration
|
||||
const AHASEND_API_KEY = process.env.AHASEND_API_KEY || 'aha-sk-A0c9WOA8cs3RpvkAGwHOP9o6pHx-gLTUki1gSWVeC_6kd86-Npn077zta-rvg9oo';
|
||||
const AHASEND_API_KEY = process.env.AHASEND_API_KEY || 'pxZ2d30PIqTl6Uj7p6g3o0uez2AacMaOstKCTcj9MTIrNEBvhikgvyAARUTvXAcA';
|
||||
const AHASEND_ACCOUNT_ID = process.env.AHASEND_ACCOUNT_ID || '8a14f9a5-6e6d-47c9-b5d6-a687265b36a3';
|
||||
const FROM_EMAIL = process.env.FROM_EMAIL || 'Beach Litter Platform <noreply@beachlitter.ie>';
|
||||
|
||||
@@ -18,20 +18,12 @@ export class EmailService {
|
||||
*/
|
||||
async sendEmail(data: EmailData): Promise<boolean> {
|
||||
try {
|
||||
// Parse from email
|
||||
const fromMatch = FROM_EMAIL.match(/<(.+)>/);
|
||||
const fromEmail = fromMatch ? fromMatch[1] : FROM_EMAIL;
|
||||
const fromName = FROM_EMAIL.replace(/<.+>/, '').trim();
|
||||
|
||||
const payload = {
|
||||
to: [{ email: data.to }],
|
||||
from: {
|
||||
email: fromEmail,
|
||||
name: fromName || 'Beach Litter Platform'
|
||||
},
|
||||
to: data.to,
|
||||
from: FROM_EMAIL,
|
||||
subject: data.subject,
|
||||
text_body: data.text,
|
||||
html_body: data.html || this.generateHtmlFromText(data.text),
|
||||
text: data.text,
|
||||
html: data.html || this.generateHtmlFromText(data.text),
|
||||
};
|
||||
|
||||
console.log('[Email] Sending request to AhaSend API...');
|
||||
@@ -39,7 +31,7 @@ export class EmailService {
|
||||
console.log('[Email] Account ID:', AHASEND_ACCOUNT_ID);
|
||||
|
||||
const response = await axios.post(
|
||||
`https://api.ahasend.com/v1/email`,
|
||||
`https://api.ahasend.com/v1/messages`,
|
||||
payload,
|
||||
{
|
||||
headers: {
|
||||
|
||||
Reference in New Issue
Block a user