Results 1 to 10 of 10
  1. #1
    Join Date
    May 2002
    Location
    Detroit, MI
    Posts
    144

    Question Pop3 Email to Mysql?

    I'm looking for a script to convert a pop3 email into a mySQL entry. Preferably with HTML formatting of the message body.

    What I'm attempting to do is be able to send an email to a specific account and have it automaticly enter the news item or calander event, or whatever table I set it for does...

  2. #2
    Join Date
    May 2001
    Location
    Montreal, Quebec
    Posts
    589
    I think you would have to make a script that would fetch the mail from the pop3 account, then replace all "\n" by "<br>" and then insert it in the database.

    You would then need a cron job to run the script via wget every hour or so.

    The downside to this is that it would sometimes take up to 1 hour for the changes to take effect but you could always set your cron job to run every 10 minutes but I think it could be a server hug.

  3. #3
    Join Date
    Aug 2002
    Location
    London, UK
    Posts
    9,037
    let me know if you come up with anything .. im interested and may help develope such a system.
    Matt Wallis
    United Communications Limited
    High Performance Shared & Reseller | Managed VPS Cloud | Managed Dedicated
    UK www.unitedhosting.co.uk | US www.unitedhosting.com | Since 1998.

  4. #4
    Join Date
    Aug 2000
    Location
    Sheffield, South Yorks
    Posts
    3,480
    You can setup a pipe in your MTA which will pipe the mail to a PHP script which can read from stdin to get the whole of the email.
    Karl Austin :: KDA Web Services Ltd.
    UK Business Hosting and Managed Servers - Hosting for Business Users :: 0800 5429 764
    Call us today and ask about our hosting solutions.

  5. #5
    Join Date
    May 2002
    Location
    Detroit, MI
    Posts
    144
    Could you say that again in English please? I understood most of it, and the theory behind it, but have no idea how to do such a thing...

    however, I did find a script that I was able to modify to do what I needed.
    -={ Dagger Hosting }=-
    -={ http://www.daggerhosting.com }=-

  6. #6
    Join Date
    Jan 2002
    Location
    Kuwait
    Posts
    679
    It depends on the kind of MTA you are using.

    edit: MTA is mail transfer agent, like: qmail, Sendmail, Exim, Postfix.
    Ahmad Alhashemi
    PHP, Apache, C, Python, Perl, SQL
    18 related BrainBench certificates

  7. #7
    Join Date
    Aug 2000
    Location
    Sheffield, South Yorks
    Posts
    3,480

  8. #8
    2illogix:
    There is no need to replace all "\n" by "<br>" before inserting data into DB. This should be done after selecting data from DB.

    2KoWind:
    I see two main ways to do it:
    1) (easiest to implement) you send "text/plain" email but in the body you place text with HTML tags. Example of email body:
    Code:
    <html>
    <body>
    <p>
    <b>News#1</b>
    <br>
    Hello world!
    </p>
    </body>
    </html>
    Your script just cuts message body and palces it into DB

    2) (a little harder to implement) you send "text/HTML" email (i.e. HTML-formated message). Then you script should parse email (extract part with "content-type=text/HTML") and put the message body into DB.

  9. #9
    Join Date
    Aug 2003
    Posts
    643
    If you plan to do this on a cpanel box you need PHP in CLI mode not CGI.

    By default (stock) its in CGI mode and gives the sender an error message even after it gets to the script. Atleast... in my case.

  10. #10

Posting Permissions

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