Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2009
    Location
    Hull
    Posts
    827
    Tokens
    0

    Latest Awards:

    Default Email to MySQL Database - PHP?

    Hey,

    Is there a way that Im able to send an email to a certain email address then get a PHP script to connect to it a extract the separate data and insert it into a database?

    +REP

    Lew.
    Im not here to be loved, I love to be hated :-}


  2. #2
    Join Date
    Feb 2006
    Location
    Scotland
    Posts
    2,087
    Tokens
    138

    Latest Awards:

    Default

    I believe it's possible, have a look here http://us2.php.net/manual/en/ref.imap.php to see the IMAP functions and then it's simply a case of storing it into the database.

  3. #3
    Join Date
    Sep 2009
    Location
    Hull
    Posts
    827
    Tokens
    0

    Latest Awards:

    Default

    So,

    This would be a case of using imap_open() to open the imap stream, then read the body with imap_body()

    Then get the script to seperate different things within the body to insert them into the database?

    Example:

    Email to: [email protected]

    Body:

    Engineer : #Lewis#
    Customer Reference : #CTI34d3r5f#
    Quote Reference : #QU4tgfS2#
    Job Category : #1#
    Job Type : #2#
    Job Description : #RANDOM JOB!#
    Equipment : #Additional Equip#

    Then get PHP to separate he values between the #'s?

    Sounds easy enough, Ill have a look into it, if anyone could suggest a way to do it, would be appreciated

    Lew.
    Im not here to be loved, I love to be hated :-}


  4. #4
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Check this out:

    http://www.phpclasses.org/package/33...-database.html

    I've never used this class but it seems to do what you want. You can modify it enough to make it work I believe.

    Remember when you're exploding / separating your data in the body, to always clean it... don't want someone to commit SQL injection through your e-mail form

  5. #5
    Join Date
    Sep 2009
    Location
    Hull
    Posts
    827
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Dentafrice View Post
    Check this out:

    http://www.phpclasses.org/package/33...-database.html

    I've never used this class but it seems to do what you want. You can modify it enough to make it work I believe.

    Remember when you're exploding / separating your data in the body, to always clean it... don't want someone to commit SQL injection through your e-mail form
    Indeed, although Ill be using it at work an no1 has a clue about opening a php tag let alone a sql injection

    Lew.
    Im not here to be loved, I love to be hated :-}


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •