Parsing email

Discussion in 'PHP' started by Hot-screensaver, Nov 21, 2006.

  1. #1
    In my database I store emails like the following:

    1. ->
    2. ->
    3. ->
    4. ...
    5. ...

    Now, when someone emails to , how can I have a script or something running somewhere on the server, that intercepts the email, reads from the database and realise that the email is actually for the actual email address which is , and forwards there. How can I do something like this?

    Any clue?
     
    Hot-screensaver, Nov 21, 2006 IP
  2. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Why use a database? PHP parsing incoming mail is a PITA - too many things it relies on (Apache as CGI etc.).

    If you use Postfix, just map it in the virtual file. /etc/postfix/virtual That sort of task is for the MTA, not for PHP.
     
    T0PS3O, Nov 21, 2006 IP
  3. Hot-screensaver

    Hot-screensaver Peon

    Messages:
    103
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    TOPS30,

    The PITA site is pretty interesting, perhaps it has something that I can use... I will read it shortly.

    I need the database, because the email address (xx@mydomain.com) are randomly generated when user registers on my site.

    Thanks.
     
    Hot-screensaver, Nov 21, 2006 IP
  4. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Just let PHP write to the MTA mapping file and execute the postmap command upon every registration. Routing email through PHP is like taking the scenic route risking getting lost.
     
    T0PS3O, Nov 21, 2006 IP
  5. Hot-screensaver

    Hot-screensaver Peon

    Messages:
    103
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I am a little lost, what is the syntax of the MTA mapping file and where can I locate it?

    I know that my server is using sendmail.
     
    Hot-screensaver, Nov 21, 2006 IP
  6. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I only know it for Postfix but sendmail is bound to have something similar. Consult their documentation to look for Postfix' equivalent of the 'virtual' file which does email mapping/redirecting.
     
    T0PS3O, Nov 21, 2006 IP
  7. Hot-screensaver

    Hot-screensaver Peon

    Messages:
    103
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Ok TOPS30, thanks for the tips.
     
    Hot-screensaver, Nov 21, 2006 IP