Giter Site home page Giter Site logo

crazy-max / cwsmailbouncehandler Goto Github PK

View Code? Open in Web Editor NEW
40.0 12.0 19.0 766 KB

📬 PHP class to help webmasters handle bounce-back, feedback loop and ARF mails in standard DSN

License: MIT License

PHP 100.00%
php imap eml-files mail bounce pop3 delivery-status-notification feedback-loop arf-mails webmasters-handle-bounce

cwsmailbouncehandler's Introduction

Latest Stable Version Minimum PHP Version Build Status Code Quality Become a sponsor Donate Paypal

⚠️ Abandoned project

This project is not maintained anymore and is abandoned. Feel free to fork and make your own changes if needed.

Thanks to everyone for their valuable feedback and contributions.

About

📬 PHP class to help webmasters handle bounce-back, feedback loop and ARF mails in standard DSN (Delivery Status Notification, RFC-1894). It checks your IMAP inbox or eml files and delete or move all bounced emails. If a bounce is malformed, it tries to extract some useful information to parse status.

Requirements

  • PHP >= 5.4
  • Enable the php_imap extension if you want to use the IMAP open mode.

Installation

composer require crazy-max/cws-mail-bounce-handler

And download the code:

composer install # or update

Getting started

See tests/test.php file sample to help you.
You can use the eml files in the tests/emls folder for testing.

Post-process

A result object Cws\MailBounceHandler\Models\Result is available to process custom post-actions :

Methods

openImapLocal - Open a IMAP mail box in local file system.
openImapRemote - Open a remote IMAP mail box.
openEmlFolder - Open a folder containing eml files on your system.

processMails - Process the messages in a mailbox or a folder.

getStatusCodeExplanations -Get explanations from DSN status code via the RFC 1893.

isMailboxOpenMode - Check if open mode is mailbox.
isFileOpenMode - Check if open mode is file.
isNeutralProcessMode - Check if process mode is neutral mode.
isMoveProcessMode - Check if process mode is move mode.
isDeleteProcessMode - Check if process mode is delete mode.
getProcessMode - The method to process bounces.
setNeutralProcessMode - Set the method to process bounces to neutral. (default)
setMoveProcessMode - Set the method to process bounces to move.
setDeleteProcessMode - Set the method to process bounces to delete.
setProcessMode - Set the method to process bounces.
getMailboxService - Mailbox service.
setImapMailboxService - Set the mailbox service to IMAP. (default)
setMailboxService - Set the mailbox service.
getMailboxHost - Mailbox host server.
setMailboxHost - Set the mailbox host server. (default localhost)
getMailboxUsername - The username of mailbox.
setMailboxUsername - Set the username of mailbox.
setMailboxPassword - Set the password needed to access mailbox.
getMailboxPort - The mailbox server port number.
setMailboxPortPop3 - Set the mailbox server port number to POP3 (110).
setMailboxPortPop3TlsSsl - Set the mailbox server port number to POP3 TLS/SSL (995).
setMailboxPortImap - Set the mailbox server port number to IMAP (143). (default)
setMailboxPortImapTlsSsl - Set the mailbox server port number to IMAP TLS/SSL (995).
setMailboxPort - Set the mailbox server port number.
getMailboxSecurity - The mailbox security option.
setMailboxSecurity - Set the mailbox security option. (default const MAILBOX_SECURITY_NOTLS)
getMailboxCert - Certificate validation.
setMailboxCertValidate - Set the certificate validation to VALIDATE.
setMailboxCertNoValidate - Set the certificate validation to NOVALIDATE. (default)
setMailboxCert - Set the certificate validation.
getMailboxName - Mailbox name.
setMailboxName - Set the mailbox name, other choices are (Tasks, Spam, Replies, etc...). (default INBOX)
getMailboxHandler - The resource handler for the opened mailbox (POP3/IMAP/NNTP/etc...).
getMaxMessages - Maximum limit messages processed in one batch.
setMaxMessages - Set the maximum limit messages processed in one batch (0 for unlimited).
isPurge - Check if purge unknown messages.
setPurge - Set the mailbox server port number.
getError - The last error message.

How can I help ?

All kinds of contributions are welcome 🙌! The most basic way to show your support is to star 🌟 the project, or to raise issues 💬 You can also support this project by becoming a sponsor on GitHub 👏 or by making a Paypal donation to ensure this journey continues indefinitely! 🚀

Thanks again for your support, it is much appreciated! 🙏

License

MIT. See LICENSE for more details.

cwsmailbouncehandler's People

Contributors

crazy-max avatar fpiccinali avatar ickbinhier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cwsmailbouncehandler's Issues

traitment of CwsMbhResult

Hi,

Tank you very much for your class but I can't use it.
How to parse the object CwsMbhResult please ?

Thx

Problem processing e-mails

I'm trying to display the number of total mails, but i'm getting this error:

Fatal error: Cannot use object of type CwsMbhResult as array
The line is:

$result = $cwsMbh->processMails();

      echo 'Número de e-mails: '.$result['counter']['total'].'<br>
          Número de e-mails analisados: '.$result['counter']['fetched'].'<br>
          Número de e-mails processados: '.$result['counter']['processed'].'<br>
          Número de e-mails não processados: '.$result['counter']['unprocessed'].'<br>
          Número de e-mails eliminados: '.$result['counter']['deleted'].'<br>
          Número de e-mails movidos: '.$result['counter']['moved'];

2 problems

  1. It is wanted that mails which are not a delivery notification are not deleted even though DeleteProcessMode is set to on.

  2. I would like to use the NeutralProcessMode and delete the mails if necessary and depending on the situation by hand. Is that possible?

Problem with Yahoo

Hello,

@crazy-max

i have added a zip file with a eml inside.

This mail is not correctly recognized as bounce mail.

Can you please check this an fix the code.

Malformed email can lead to warnings

In MailBounceHandler\Handler:

parseDsnFields() can return null for the 'perRecipient' element of the result array.

This ends in a warning in parseBodySectionMachine() on line 877 because 'perRecipient' is not an array.

No way to get mail content and headers?

After Handler->processMails() i did not find any way to get mail headers or content.

This would be very handy when the processed mail has Handler::CAT_UNKNOWN or Handler::CAT_UNRECOGNIZED. We could save the bounced email to DB (or any other source) and later examine it by hand and mark it as soft/hard bounce or to enhance the process and declare new rules.

Is there any way to get the same results without extending your classes? And would you be interested in such Pull request?

problem with imap_open

in class Handler in function openImapRemote line 295

I get some error messages when calling imap_open.

'imap_open(): Couldn't open stream {xxxx.tu-braunschweig.de:993/imap/ssl/validate-cert}INBOX', '/var/www-aaaa/releases/111/vendor/crazy-max/cws-mail-bounce-handler/lib/Cws/MailBounceHandler/Handler.php', 299, array('opts' => '/imap/ssl/validate-cert')

I have already placed the call to openImapRemote in a try catch.

Does it make sense to use a try catch in the openImapRemote function?

What about using composer.json ?

et si on mettait en place un composer.json.

Composer facilite la mise en place et les mises à jour. Il automatise les mises à jour et gère les dépendances.

Je vais proposer une pull request dans ce sens.

@crazy-max : que penses-tu de découpler la classe principale de ses dépendancs avec les class de debug et de dump ? On aurait ainsi une class autonome et chacun pourrait utiliser son débuggeur préféré. Je penses en particulier lors d' une intégration dans symfony.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.