ImapMailMerge/README.md

2.1 KiB

ImapMailMerge

Program for simulating the effect of "mail merge" for IMAP emails. The program uses the "Reply-To:" header to send individual messages to one or more recipients. This helps address issues with deliverability when there are many CC or TO addresses, or when To and From are the same, with many CC addresses.

*note -- this program might not be able to send to non-local address on shared hosting.

<br >

Requirements

Make sure all dependencies have been installed before using this program:

  • PHP ~ tested on PHP 7.4
  • Mailserver with IMAP connectivity (can be remote)

<br >

Project Installation

Install this program via git pull:

$ git clone https://gitea.dubtempo.com/NP/ImapMailMerge.git

<br >

Project Usage

To use this program, complete the following steps.

  1. Copy the sample config file "config/config.ini.example" to "config/config.ini".

  2. Update the variables in the config file: config/config.ini.

  3. Be sure to use the "whitelist" in the config for addresses you'd like to be able use the mailmerge.

  4. Run the program manually or by referencing it via cronjob.


How it works

Here's a basic overview of how the code works.

  1. Emails are sent to the mailmerge account, eg: mailmerge@example.com.

  2. When the program is called (eg: via cronjob), the INBOX is searched for new messages.

  3. Messages in the INBOX are processed in the following way:

    1. The FROM address is verified against the whitelist.

    2. A new IMAP directory is made based on the sender's name.

    3. Sub directories are also made for that sender: Error / Fail / Success.

    4. Intended recipients are deduced from the Reply-To addresses specified in the message.

  4. Messages are then sent via php mail().

  5. Upon completion, the message is moved to the appropriate IMAP directory based on the outcome of the mail() attempt.


Debugging

You can debug this code by looking at the error logs. Uncomment the logging lines in ImapMailMerge.php for more info.