Email Notifications

Automatically notify customers when new documents are available. The email notification system uses a queue-based approach with retry logic and delivery tracking.

How It Works

  1. Queue Creation - When a document is saved with "Send Email" enabled, notification entries are created for all assigned customers
  2. Cron Processing - The SendDocumentNotification cron job processes pending notifications in batches of 100
  3. Email Delivery - Emails are sent with configurable templates, CC/BCC recipients, and optional file attachments
  4. Status Tracking - The system tracks delivery status (pending/sent/failed) and retry attempts

Configuration

Email Settings

Navigate to Stores >Configuration > MageB2B > Customer Documents > Email Settings.

Email Sender

Select which store email identity to use as the sender (General Contact, Sales Representative, etc.)

Email Template

Choose the email template for document notifications. You can customize this template under Marketing >Email Templates.

CC Receivers

Enter email addresses to receive copies of all notifications. Separate multiple addresses with semicolons (;).

Example: manager@example.com;admin@example.com

BCC Receivers

Enter email addresses for blind carbon copies. Recipients won't see each other's addresses.

Add File as Attachment

Enable this to attach the document file to the email (subject to size limits).

File Attachment Settings

Maximum Email Attachment Size

Set the maximum file size (in MB) for email attachments:

Path: Stores > Configuration > MageB2B > Customer Documents > General Settings > Maximum Email Attachment Size (MB)

  • 0 = No limit (not recommended - may cause mail server issues)
  • Recommended: 5-10 MB
  • Files larger than this limit will not be attached to emails

Why limit attachment size?

  • Prevents mail server rejection
  • Avoids inbox quota issues
  • Improves email delivery reliability

Sending Notifications

Manual Sending (Admin)

  1. Navigate to Customers >Customer Documents > All Documents
  2. Select documents using checkboxes
  3. Choose Actions >Send Email
  4. Click Submit
  5. Notifications are queued and will be sent by the next cron run

Automatic Sending (On Save)

When creating or editing a document:

  1. Enable the Send Email checkbox in the document form
  2. Save the document
  3. Notifications are automatically queued for all assigned customers

Notification Queue

Viewing the Queue

Navigate to Customers >Customer Documents > E-Mail Notification to see:

  • Document name
  • Customer email
  • Status (Pending/Sent/Failed)
  • Attempt count
  • Created/Sent timestamps
  • Error messages (if failed)

You can also re-send selected records from this grid using the available mass action.

Status Types

StatusDescription
PendingWaiting to be sent by cron job
SentSuccessfully delivered
FailedDelivery failed after 3 attempts

Retry Logic

  • Maximum attempts: 3
  • Batch size: 100 notifications per cron run
  • Retry interval: Next cron execution (every 30 minutes by default)

Cron Job

SendDocumentNotification

Schedule: Every 30 minutes (*/30 * * * *)

What it does:

  1. Fetches pending notifications (max 100 per run)
  2. Loads document and customer data
  3. Checks file size against attachment limit
  4. Sends email with or without attachment
  5. Updates notification status
  6. Logs statistics

Monitoring

Check cron execution logs:

tail -f var/log/system.log | grep "Document notification"

View statistics in logs:

Document Notification Statistics: {"Pending": 45, "Sent": 1203, "Failed": 12}

Email Template Variables

When customizing email templates, you can use these variables:

VariableDescription
{{var customerdocument.name}}Document name
{{var customerdocument.description}}Document description
{{var customer_firstname}}Customer first name
{{var customer_lastname}}Customer last name
{{var customer_email}}Customer email

Cleanup

Delete Old Notifications

Configure automatic cleanup of old notifications:

Path: Stores > Configuration > MageB2B > Customer Documents > General Settings > Delete notifications after X days

  • Pending/Sent/Failed notifications older than X days will be deleted
  • Helps keep the database clean
  • Recommended: 30-90 days

Troubleshooting

Emails Not Sending

Check cron execution:

php bin/magento cron:run

Verify email configuration:

  • Stores >Configuration > General > Store Email Addresses
  • Test with a simple Magento email (password reset, order confirmation)

Check notification queue:

  • Navigate to Email Notifications grid
  • Look for error messages in failed notifications

Attachments Not Included

File too large:

  • Check the file size against your configured limit
  • Increase the limit or reduce file size

External documents:

  • External URLs (is_external = 1) cannot be attached
  • Only local files can be attached to emails

File missing:

  • Verify the file exists on the filesystem
  • Check the upload path configuration

High Failure Rate

Mail server limits:

  • Your mail server may have rate limits
  • Stagger large sends and monitor SMTP/provider limits

Invalid email addresses:

  • Check customer email addresses for typos
  • Clean up invalid addresses in customer data

Attachment size:

  • Large attachments may be rejected by recipient mail servers
  • Reduce the maximum attachment size limit

Best Practices

  • Test email templates - Send test emails before mass notifications
  • Monitor the queue - Regularly check for failed notifications
  • Set reasonable limits - Keep attachment size under 10 MB
  • Use BCC for monitoring - Add admin email to BCC for oversight
  • Clean up old notifications - Enable automatic cleanup to maintain performance
  • Don't send too frequently - Respect customer preferences and avoid spam
  • Don't attach huge files - Use download links instead of large attachments

Found an issue with this documentation? Let us know