Author Topic: Redirecting 'headless'  (Read 8110 times)

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14337
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Redirecting 'headless'
« on: August 14, 2017, 10:48:13 AM »
So this is sort of related to my other topic on mail parsing.  Here's my situation:


1) I have a PSR compliant app that I wrote using Slim as the router
2) I have this requirement to catch incoming mail
3) I setup the subdomain for the emails which points to a specific file that catches the email and does some basic processing (basically grabbing the message and writing it to disk for now)
4) I want to forward that caught action to the app because I want to run the remaining aspects of the processing in the context of the application where I have a bunch of routines for logging audits and adding details from the message to the interface.  If I don't, I have to recreate a bunch of processing.  Obviously that request isn't coming from a browser and it doesn't appear that a php 'header()' redirect is working. 


Is there a way to that mail catch functionality go to a URL instead of a single file or is there a way to forward the mail catch functionality into my app?  Is this even making sense?

KnuckleBuckett

  • Jackass In Charge
  • Posts: 8674
  • Karma: +26/-259
  • [url=http://google.com]I search a lot[/url]
Re: Redirecting 'headless'
« Reply #1 on: August 15, 2017, 06:05:34 AM »
Wait a couple minutes.  It'll come to you.

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14337
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: Redirecting 'headless'
« Reply #2 on: August 15, 2017, 07:28:26 AM »
Hahahhaa

Mike

  • Jackass In Charge
  • Posts: 11270
  • Karma: +168/-32
  • Ex Asshole - a better and more caring person.
Re: Redirecting 'headless'
« Reply #3 on: August 15, 2017, 08:14:47 AM »
What are you using to catch the mail?  And what are you using to forward the request?  And what are your restrictions (e.g. can you change the SMTP program?)

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14337
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: Redirecting 'headless'
« Reply #4 on: August 15, 2017, 08:47:14 AM »
I created a subdomain and I'm just using a catch-all mechanism in Cpanel to say 'send all mail to this subdomain to this php file'.  According to the docs, I have to use a local path which removes my ability to just point that to a URL that my app would normally process.  I had tried the other night to take the mail message and write it to a text file and then redirect using header() to a path in my actual application where I would read that file off the disk and process it.  But it never gets into the application.  It's like it ignores the header call.

I'm not really using an SMTP program.  Emails come into the server and I just grab the stream from stdin and drop it to a file.  I guess one way to do it would be to dump all the emails to an inbox and then read from the inbox but that would still be via cron job which also points to a file, not an application path.

I feel like I'm thinking about this the wrong way or something.

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14337
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: Redirecting 'headless'
« Reply #5 on: August 15, 2017, 11:55:16 AM »
I posted this on StackOverflow and I think I got a decent suggestion: https://stackoverflow.com/questions/45693479/piping-email-to-php-app

Mike

  • Jackass In Charge
  • Posts: 11270
  • Karma: +168/-32
  • Ex Asshole - a better and more caring person.
Re: Redirecting 'headless'
« Reply #6 on: August 15, 2017, 06:00:07 PM »
Yeah, I agree with Francis.  Except, I'd do it in Python and not PHP :P

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14337
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: Redirecting 'headless'
« Reply #7 on: August 15, 2017, 07:44:50 PM »
I keep hearing about people using Python but I've never dabbled in it.

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14337
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: Redirecting 'headless'
« Reply #8 on: August 17, 2017, 08:28:41 AM »
FYI, the answer on StackOverflow worked like a dream.