I want to override the send() function in SugarPHPMailer.
This is what I have:
custom/modules/Administration/JJW_MSGraphMailer/
βββ src/
β βββ TokenStore.php # Manages OAuth tokens in database
β βββ GraphMailer.php # Sends emails via Microsoft Graph API
β βββ Helpers.php # Utility functions (config, logging)
β βββ Installer.php # Creates database tables
βββ autoload.php # Class autoloader
custom/modules/Administration/views/
βββ view.msgraphmailer.php # Admin configuration page
# - OAuth setup
# - User management
# - Test emails
# - Send logs
custom/include/SugarPHPMailer/
βββ SugarPHPMailer.php # Overrides SuiteCRM's email system
# - Intercepts all system emails
# - Routes through GraphMailer
# - No SMTP fallback
custom/Extension/application/Ext/Include/
βββ CustomMailerLoader.php # Forces SuiteCRM to load custom mailer
jjw_msgraph_tokens # Stores OAuth access/refresh tokens
jjw_msgraph_send_log # Logs all email attempts
config (category: JJW_MSGraphMailer) # Settings storage
Admin β MSGraphMailer # Configuration interface
System emails β GraphMailer # Automatic routing
Test emails β GraphMailer # Direct API calls
SuiteCRM Email β SugarPHPMailer β GraphMailer β Microsoft Graph API β Recipient
β
Send Log Database
I have everythign working great. I still have to set up a cron job to send keepalive emails. I came up with this idea with my webpage when I created a WP plugin to use MS GraphMail and it has been working great for months. I can send test emails from my admin settings page but I cant send system default emails as I cannot seem to override the SugarPHPMailer Send function. I have my own send function that users GraphMailer.
How do I override Send in SugarPHPMailer.
I thought that the class_override.php that I have in custom/include/SugarPHPMailer would do this. it contains: <?php
$GLOBALS['SugarPHPMailerOverride'] = 'SugarPHPMailer';
I also have SugarPHPMailer.php in custom/include.SugarPHPMailer. that has this:
<?php
// File: custom/include/SugarPHPMailer/SugarPHPMailer.php
// Custom SugarPHPMailer that routes emails through Microsoft Graph
require_once 'include/SugarPHPMailer.php';
require_once 'custom/modules/Administration/JJW_MSGraphMailer/src/TokenStore.php';
require_once 'custom/modules/Administration/JJW_MSGraphMailer/src/GraphMailer.php';
use JJW_MSGraphMailer\TokenStore;
use JJW_MSGraphMailer\Src\GraphMailer;
class SugarPHPMailer extends PHPMailer
{
public function Send()
{ ...
Can anyone help me out?