0

I am looking to set up one PHP file to sort and respond to emails. It is sort of a subscription-based email alert system.

So I need script that will check the body content of an email, then respond to the email with some small amount of plain text.

For example: Email from user = A Email from server = B

B: Thank you for your subscription! Reply YES to confirm or CANCEL. A: YES B: You've been added to the list.

Then I would also need code to add email address to a mailing list and also code to remove email from mailing list.

I am using cPanel to create mailing list and set up a filtering system which only allows Pipe to Program, no respond with templates.

I have researched the topic, but there are not that many references anywhere on this type of coding.


MAIN FOCUS:

  • If body of email contains "XXX" then respond with body only "YYY".
  • If body of email contains "XXX" then add email to mailing list and respond with body only "YYY".
Andrew Manson
  • 280
  • 1
  • 8
  • Since you're question is sort of general, I'll [point you toward this answer on Mail_mimeDecode](http://stackoverflow.com/a/7028828/541091) The PHP script's logic to send emails based on the input, I leave to you because it is fairly simple logic. Parsing the input message is the hard part. – Michael Berkowski Feb 12 '15 at 00:24
  • 1
    There is also [this answer](http://stackoverflow.com/questions/3662295/how-do-i-get-just-the-text-content-from-a-multipart-email/3662746#3662746) which focuses on the text body content of MIME messages with string parsing. – Michael Berkowski Feb 12 '15 at 00:30
  • @MichaelBerkowski I am so lost, this part of PHP is out of my range. So I want to read emails from the server, which is the first part of the code, I understand that, but then let's say, the body of the email is "YES" and the subject is "SUB_CONFIRM", then I want to respond to the email with "Thank You" excluding all headers, just "Thank You" in the body. But also if the email says something else with another subject, respond with something else. IN addition, add email address to a mailing list. – Andrew Manson Feb 12 '15 at 00:39
  • Assembling the logic is manyfold. Start with [PHPMailer](https://github.com/Synchro/PHPMailer) for an easy path to send messages. I don't recommend trying to use the built-in `mail()` function. When you have read the body into a var `$body` using one of the linked methods, conditional logic like `if ($body == 'YES') {// simple Thank You response}` PHPMailer's readme file has an excellent starting example. – Michael Berkowski Feb 12 '15 at 04:52

0 Answers0