Overview
This endpoint allows pastors to send email notifications to all members of their church. The email is sent using BCC (blind carbon copy) to protect member privacy, ensuring recipients cannot see other members’ email addresses.
This endpoint requires pastor role authentication. Only the pastor who created the church can send emails to its members.
Authentication
This endpoint requires:
- Valid JWT token in the Authorization header
- User must have the pastor role
- Pastor must be the owner of the specified church
Request
The unique identifier of the church whose members will receive the email
The unique identifier of the pastor sending the email. Must match the authenticated user’s ID and the church’s pastor ID
The subject line of the email
The body content of the email. Supports HTML formatting
Example Request
curl -X POST https://api.example.com/api/church/sendemailtoall \
-H "Content-Type: application/json" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
-d '{
"churchId": "507f1f77bcf86cd799439011",
"pastorId": "507f191e810c19729de860ea",
"subject": "Sunday Service Reminder",
"message": "Dear members, this is a reminder that our Sunday service starts at 10 AM. We look forward to seeing you there!"
}'
const response = await fetch('https://api.example.com/api/church/sendemailtoall', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({
churchId: '507f1f77bcf86cd799439011',
pastorId: '507f191e810c19729de860ea',
subject: 'Sunday Service Reminder',
message: 'Dear members, this is a reminder that our Sunday service starts at 10 AM. We look forward to seeing you there!'
})
});
const data = await response.json();
console.log(data);
Response
Indicates whether the email was sent successfully
Human-readable message describing the result
Array of email addresses that received the message
Success Response
Error Responses
Unauthorized - Not Pastor
{
"success": false,
"message": "Unable to send emails",
"data": "You are not the pastor of this church"
}
Church Not Found
{
"success": false,
"message": "Unable send email",
"data": "Church with this Id does not exist"
}
No Members Found
{
"message": "No members found"
}
Server Error
{
"success": false,
"message": "Unable to send emails",
"data": "Error message details"
}
Implementation Details
Email Service
The system uses Nodemailer with Brevo (formerly Sendinblue) SMTP relay service to send emails:
- Host: smtp-relay.brevo.com
- Port: 587
- Security: STARTTLS
Privacy Protection
Emails are sent using the BCC (blind carbon copy) field to ensure:
- Recipients cannot see other members’ email addresses
- Each member’s privacy is protected
- Professional email delivery standards are maintained
The “from” field is set to the church name, providing context to recipients about the email’s origin.
HTML Support
The message body supports HTML formatting, allowing pastors to:
- Format text with bold, italics, and other styles
- Include links and images
- Create structured email content
Use Cases
- Service Announcements: Notify members about upcoming services or schedule changes
- Event Invitations: Invite members to special church events or activities
- Prayer Requests: Share prayer requests with the congregation
- Newsletter Distribution: Send regular updates about church activities
- Emergency Notifications: Communicate urgent information to all members
Best Practices
- Keep Messages Concise: Write clear, focused messages that respect members’ time
- Use Descriptive Subjects: Craft subject lines that clearly indicate the email’s purpose
- Test HTML Content: Ensure HTML formatting displays correctly across email clients
- Respect Frequency: Avoid sending too many emails to prevent member fatigue
- Include Contact Info: Provide a way for members to respond or ask questions