Project
category Bounce Mail Handling
package PHPMailer-BMH
author Andy Prevost
copyright 2004-2023 (C) Andy Prevost - All Rights Reserved
version 7.0.0
license MIT - Distributed under the MIT License
namespace codeworxtech\PHPMailerBMH;
class PHPMailerBMH
const
scope property default value comments
const BMH_EOL "<br>\n";  
const CHECKMARK "&#10004;"  
const CRLF "\r\n"  
const R_ARROW "&rarr;"  
const TIMEOUT 60;  
const VERBOSE_QUIET 0;  
const VERBOSE_REPORT 2;  
const VERBOSE_SIMPLE 1;  
const VERBOSE_DEBUG 3;  
const VERSION "7.0.0"  
public
scope property default value comments
public $actionFunction callbackAction Callback Action function name
(function that handles the bounce mail)
see samples for details
public $boxname INBOX Mailbox type, default is 'INBOX', other choices are (Tasks, Spam, Replies, etc.)
@var string
public $debugDsnRule false control failed DSN rules Output
@var boolean
public $debugBodyRule false control failed BODY rules Output
@var boolean
public $deleteMsgDate Deletes messages globally prior to date in variable
NOTE: excludes any message folder that includes 'sent' in mailbox name
format is same as MySQL: 'yyyy-mm-dd'
if variable is blank, will not process global delete
@var string
public $disableDelete false If disableDelete is equal to true, it will disable the delete function
@var boolean
public $emptyTrash false  
public $errorMessage; Last error msg
@var string
public $hardMailbox INBOX.hard Mailbox folder to move hard bounces to, default is 'hard'
@var string
public $mailhost localhost Mail server
@var string
public $mailboxPassword; Mailbox password
@var string
public $mailboxUserName; Mailbox username
@var string
public $maxMessages 3000 Maximum messages processed in one batch
@var int
public $moveHard false Determines if hard bounces will be moved to another mailbox folder
NOTE: If true, this will disable delete and perform a move operation instead
@var boolean
public $moveSoft false Determines if soft bounces will be moved to another mailbox folder
@var boolean
public $port 143 Defines port number, default is '143', other common choices are '110' (pop3), '993' (gmail)
@var integer
public $purgeUnprocessed false Purge the unknown messages (or not)
@var boolean
public $service imap Defines service, default is 'imap', choice includes 'pop3'
@var string
public $serviceOption notls Defines service option, default is 'notls', other choices are 'tls', 'ssl'
@var string
public $softMailbox INBOX.soft Mailbox folder to move soft bounces to, default is 'soft'
@var string
public $testMode false Test mode, if true will not delete messages
@var boolean
public $trashBoxes [Trash,Spam,Junk] Trash folders to delete (there are under the 'INBOX'
as in INBOX.Trash / INBOX.Spam / INBOX.Junk
@var array
public $useFetchstructure true Control the method to process the mail header
if set true, uses the imap_fetchstructure function
otherwise, detect message type directly from headers,
a bit faster than imap_fetchstructure function and take less resources.
however - the difference is negligible
@var boolean
public $verbose self::VERBOSE_SIMPLE Control the debug Output, default is VERBOSE_SIMPLE
@var int
private
scope property default value comments
private $countAged 0  
private $countTrash 0  
private $divError <div class=\bmh-alert bmh-danger\ role=\alert\> %s </div>;=  
private $divInfo <div class=\bmh-alert bmh-info\ role=\alert\> %s </div>;=  
private $htmlStyle <style>.bmh-alert {border-radius:5px;border-style:solid;border-width:1px;font-family:sans-serif;font-size:20px;font-weight:bold;padding:12px 16px;width:80%;}.bmh-alert.bmh-danger {background-color:rgba(248, 215, 218, 1);border-color:rgba(220, 53, 69, 1);color:rgba(114, 28, 36,1);line-height:1.5;}.bmh-alert.bmh-info {background-color:rgba(217, 237, 247, 1);color:rgba(49, 112, 143, 1);border-color:rgba(126, 182, 193, 1);line-height:1.5;}</style>  
private $language []  
private $mailboxConn false  
private $msgErrors  
private $msgInfo  
protected
scope property default value comments
protected $rule_categories [  
Methods
scope function params comments
public GetVersion Class Constructor


Get version
@return string
public ProcessAged Function to delete messages in a mailbox, based on date
NOTE: this is global ... will affect all mailboxes except any that have 'sent' in the mailbox name
public ProcessTrash Process the messages in a mailbox
@param string $max maximum limit messages processed in one batch
@return boolean
array_walk($this->trashBoxes, &$value  
public IsParameter $currParameters, $varKey, $varValue Function to determine if a particular value is found in a imap_fetchstructure key
@param array $currParameters imap_fetstructure parameters
@param string $varKey imap_fetstructure key
@param string $varValue value to check for
@return boolean
public MailboxExist $mailbox, $create = true Function to check if a mailbox exists
- if not found, it will create it
@param string $mailbox the mailbox name, must be in 'INBOX.checkmailbox' format
@param boolean $create whether or not to create the checkmailbox if not found, defaults to true
@return boolean
public OpenLocal $filePath Open a mail box in local file system
@param string $filePath The local mailbox file path
@return boolean
public MailboxClose $object,$echo=false  
public MailboxOpen Open a mail box
@return boolean
public Output $msg, $type="info", $verboseLevel=1 Output additional msg for debug
@param string $msg if not given, Output the last error msg
@param string $verboseLevel the Output level of this message
public ProcessBounce $pos, $type, $totalFetched  
public ProcessMailbox $max = false Process the messages in a mailbox
@param string $max maximum limit messages processed in one batch, if not given uses the property $maxMessages
@return boolean
private RulesBody $body,$structure,$debug_mode=false Defined bounce parsing rules for non-standard DSN
@param string $body body of the email
@param string $structure message structure
@param boolean $debug_mode show debug info. or not
@return array $result an array include the following fields: 'email', 'bounce_type','remove','rule_no','rule_cat'
if we could NOT detect the type of bounce, return rule_no = '0000'
private RulesDSN $dsn_msg,$dsn_report,$debug_mode=false sample:
xxxxx@yourdomain.com
no such address here

sample:
:
111.111.111.111 does not like recipient.
Remote host said: 550 User unknown

sample:

sample:
:
Sorry, no mailbox here by that name. vpopmail (#5.1.1)

sample:
xxxxx@yourdomain.com

local: Sorry, can't find user's mailbox. (#5.1.1)


sample:
##########################################################
# This is an automated response from a mail delivery #
# program. Your message could not be delivered to #
# the following address: #
# #
# "|/usr/local/bin/mailfilt -u #dkms" #
# (reason: Can't create Output) #
# (expanded from: ) #
# #

sample:
????????????????:
xxxxx@yourdomain.com : ????, ?????.

sample:
xxxxx@yourdomain.com
Unrouteable address

sample:
Delivery to the following recipients failed.
xxxxx@yourdomain.com

sample:
A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:
xxxxx@yourdomain.com
unknown local-part "xxxxx" in domain "yourdomain.com"

sample:
:
111.111.111.11 does not like recipient.
Remote host said: 550 Invalid recipient:

sample:
Sent >>> RCPT TO:
Received <<< 550 xxxxx@yourdomain.com... No such user
Could not deliver mail to this user.
xxxxx@yourdomain.com
**************** End of message ***************

sample:
Diagnostic-Code: X-Notes; Recipient user name info (a@b.c) not unique. Several matches found in Domino Directory.

sample 1:
:
This account is over quota and unable to receive mail.
sample 2:
:
Warning: undefined mail delivery mode: normal (ignored).
The users mailfolder is over the allowed quota (size). (#5.2.2)

sample:
----- Transcript of session follows -----
mail.local: /var/mail/2b/10/kellen.lee: Disc quota exceeded
554 ... Service unavailable

sample:
Hi. This is the qmail-send program at 263.domain.com.
:
- User disk quota exceeded. (#4.3.0)

sample:
xxxxx@yourdomain.com
mailbox is full (MTA-imposed quota exceeded while writing to file /mbx201/mbx011/A100/09/35/A1000935772/mail/.inbox):

sample:
The message to xxxxx@yourdomain.com is bounced because : Quota exceed the hard limit

sample:
Message rejected. Not enough storage space in user's mailbox to accept message.

sample:
:
This address no longer accepts mail.

sample:
xxxxx@yourdomain.com

553 user is inactive (eyou mta)

sample:
xxxxx@yourdomain.com [Inactive account]

sample1:
Delivery to the following recipient failed permanently:
a@b.c
Technical details of permanent failure:
TEMP_FAILURE: Could not initiate SMTP conversation with any hosts:
[b.c (1): Connection timed out]
sample2:
Delivery to the following recipient failed permanently:
a@b.c
Technical details of permanent failure:
TEMP_FAILURE: Could not initiate SMTP conversation with any hosts:
[pop.b.c (1): Connection dropped]

sample:
Delivery to the following recipient has been delayed:
a@b.c
Message will be retried for 2 more day(s)
Technical details of temporary failure:
TEMP_FAILURE: Could not initiate SMTP conversation with any hosts:
[b.c (50): Connection timed out]

sample:
Delivery to the following recipient has been delayed:
a@b.c
Message will be retried for 2 more day(s)
Technical details of temporary failure:
TEMP_FAILURE: The recipient server did not accept our requests to connect. Learn more at ...
[b.c (10): Connection dropped]

sample:
:
Unable to switch to /var/vpopmail/domains/domain.com: input/Output error. (#4.3.0)

sample:
:
can not open new email file errno=13 file=/home/vpopmail/domains/fromc.com/0/domain/Maildir/tmp/1155254417.28358.mx05,S=212350

sample:
:
111.111.111.111 failed after I sent the message.
Remote host said: 451 mta283.mail.scd.yahoo.com Resources temporarily unavailable. Please try again later [#4.16.5].

sample:
AutoReply message from xxxxx@yourdomain.com

sample:
Delivery to the following recipient failed permanently:
a@b.c
Technical details of permanent failure:
PERM_FAILURE: SMTP Error (state 9): 550 5.7.1 Your message (sent through 209.85.132.244) was blocked by ROTA DNSBL. If you are not a spammer, open http://www.rota.lv/DNSBL and follow instructions or call +371 7019029, or send an e-mail message from another address to dz@ROTA.lv with the blocked sender e-mail name.

sample:
Failed to deliver to ''
Messages without To: fields are not accepted here

sample:
:
The user does not accept email in non-Western (non-Latin) character sets.

sample:
554 delivery error
This user doesn't have a yahoo.com account

sample:
550 hotmail.com

sample:
550 5.1.1 aim.com

sample:
550 .(in reply to end of DATA command)

sample:
550 .(in reply to RCPT TO command)

sample:
a@b.c:
unrouteable mail domain "b.c"


Defined bounce parsing rules for standard DSN (Delivery Status Notification)
@param string $dsn_msg human-readable explanation
@param string $dsn_report delivery-status report
@param boolean $debug_mode show debug info. or not
@return array $result an array include the following fields: 'email', 'bounce_type','remove','rule_no','rule_cat'
if we could NOT detect the type of bounce, return rule_no = '0000'
private SetLanguage $langcode = 'en', $lang_path = 'language/'