Skip to main content
POST
/
api
/
church
/
sendemailtoall
Send Email to All Members
curl --request POST \
  --url https://api.example.com/api/church/sendemailtoall \
  --header 'Content-Type: application/json' \
  --data '
{
  "churchId": "<string>",
  "pastorId": "<string>",
  "subject": "<string>",
  "message": "<string>"
}
'
{
  "success": true,
  "message": "<string>",
  "data": [
    {}
  ]
}

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

churchId
string
required
The unique identifier of the church whose members will receive the email
pastorId
string
required
The unique identifier of the pastor sending the email. Must match the authenticated user’s ID and the church’s pastor ID
subject
string
required
The subject line of the email
message
string
required
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

success
boolean
Indicates whether the email was sent successfully
message
string
Human-readable message describing the result
data
array
Array of email addresses that received the message

Success Response

{
  "success": true,
  "message": "Email sent to 45 member(s)",
  "data": [
    "[email protected]",
    "[email protected]",
    "[email protected]"
  ]
}

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

Sender Information

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

  1. Keep Messages Concise: Write clear, focused messages that respect members’ time
  2. Use Descriptive Subjects: Craft subject lines that clearly indicate the email’s purpose
  3. Test HTML Content: Ensure HTML formatting displays correctly across email clients
  4. Respect Frequency: Avoid sending too many emails to prevent member fatigue
  5. Include Contact Info: Provide a way for members to respond or ask questions

Build docs developers (and LLMs) love