Function: JScms_send_email
avatar
Señor FAQ

¡Hola, amigos! I’m Señor FAQ, the mustached maestro of questions and answers! With my trusty glasses and a book of endless wisdom, I turn dudas into solutions. Soy el héroe de los curiosos and the champion of clarity.


Function: JScms_send_email

The JScms_send_email function stores email information in the database for later sending by a cron job. It handles multiple recipients, CC addresses, and file attachments, ensuring email data is queued properly for processing.

Syntax


JScms_send_email($jakdb, $mailaddress, $mailccaddress, $replyto, $subject, $message, $emailfiles)
    

Parameters

  • $jakdb: (object) The database connection instance.
  • $mailaddress: (string|array) The recipient email address(es).
  • $mailccaddress: (string|array) The CC email address(es).
  • $replyto: (string) The reply-to email address.
  • $subject: (string) The email subject.
  • $message: (string) The email body content.
  • $emailfiles: (string|array) The file attachments for the email.

Returns

(bool) Returns true if the email information was successfully stored in the database, or false if an error occurred.

Example Usage


<?php
$result = JScms_send_email(
    $jakdb, 
    "recipient@example.com", 
    ["cc1@example.com", "cc2@example.com"], 
    "replyto@example.com", 
    "Subject Line", 
    "This is the email body content.", 
    ["path/to/file1.pdf", "path/to/file2.jpg"]
);

if ($result) {
    echo "Email queued successfully.";
} else {
    echo "Failed to queue email.";
}
?>
    

Best Practices

  • Validate all email addresses before passing them to the function to ensure proper formatting.
  • Use appropriate status codes and database schema to manage email queue processing efficiently.
  • Ensure attachments are securely uploaded and accessible before storing their paths in the database.
  • Configure your cron job to process the email queue at regular intervals to avoid delays.

Common Issues

  • Invalid Email Addresses: The function will fail if any recipient email address is not valid.
  • Database Connection: Ensure that the database connection $jakdb is properly configured and available.
  • Attachment Paths: Verify that file paths provided in $emailfiles are correct and accessible by the system.
Was this article helpful?
0 out of 0 found this helpful