The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How save all mail in MySQL DB ?

Discussion in 'E-mail Discussions' started by Mejoramos.com, Jun 22, 2005.

  1. Mejoramos.com

    Mejoramos.com Member

    Joined:
    Feb 11, 2004
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    Hello,

    is possible save ALL mail in a BD MySQL ?

    How ?

    But atention: without using CRON

    CRON = Machine Slow.

    And 1 cron each 5 or < minutes no is a great idea!.

    I no know how is possible run a script.php, (I know very good PHP), each time arrive a mail to my server.

    If customer send mail = run scrip.php => how is possible without using CRON ?

    If NO IS POSSIBLE please sayme and i no seek more.

    (In this case i used a CRON), but i no want used CRON for this.

    My english no very good, sorry and THANKS!!!.
     
  2. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    You can simply email using a pipe in a Forwarder. So, to run a script in /home/username/myscript.php you would setup a Forwarder for the address with the following:

    |/home/username/myscript.php
     
  3. Mejoramos.com

    Mejoramos.com Member

    Joined:
    Feb 11, 2004
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    I am mistake ?

    Master:

    My opinion: CRON each < of 5 minutes = bad action for server.... (degrade in slow)

    But you opinion ?
     
  4. yodabear

    yodabear Member

    Joined:
    May 31, 2005
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    We are using here DBMail. When a message was received it is saved emediatly into a mysql or postgres database.
     
  5. Mejoramos.com

    Mejoramos.com Member

    Joined:
    Feb 11, 2004
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    DBMail


    Thanks,

    I go to [ http://www.dbmail.org/index.php?page=download ]

    -------------------------------

    I try [|/home/username/myscript.php]
    And I try [/home/username/myscript.php]
    And I try [http://myweb/myscript.php]

    Nothing run...

    :confused:

    Who know the "Tips" for save all mail in a DB ?

    DBMail is all a software, (C++,PHP,C)...

    Someboy know the "tips" for save all mail in a DB MySQL ?

    Regards.
     
  6. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    36
    When piping to a script, you need to ensure that the permissions are set correctly on a script.

    The script in question will normally only be executable by the account holder. However when piping to a script, it needs to be more widely executable.

    Set the PHP relevant PHP script permissions to 0755 and work down from there if this is not secure enough for you.

    Also check /var/log/exim_mainlog for error messages when piping mail.
     
  7. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    36
  8. drupal

    drupal Active Member

    Joined:
    Jun 23, 2005
    Messages:
    29
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Not here, but there.
    Does anyone have a sample of the script to insert into the database? This would be a cool thing to add to cpanel.
     
  9. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    36
    When creating a new filter (cpanel > mail > e-mail filtering > add filter), enter into the Destination field something of the following:

    Code:
    | /home/username/script.php
    The script does not have to reside in your public_html directory, however you must ensure that the directory in which the script resides has suitable permissions so that the script within can be read and executed.

    Other than that, just follow the pointers in the thread I referenced above and you should be fine.

    A couple of handy things to think about and look out for when things don't work:

    1. Try to execute the relvant script from the command line:

    Code:
    /usr/local/bin/php /home/username/script.php
    Doing so will make any errors jump out and be astoundingly obvious.

    2. Any includes used in the script to which mail is piped must use absolute paths and can not be related to $_SERVER['document_root'] or similar

    3. If any problem with piping the mail is encountered, a delivery failure message will be returned to the sender. This will occur if:

    - the script has insufficient permissions to be executed. If there is no clear error in the delivery failure message, this is the most likely cause.

    - a runtime error was encountered when executing the PHP script. If so, the PHP error (if you have error reporting turned on) will be included in the delivery failure message (very useful)

    - a delivery failure message will be returned to the sender if the PHP script does not read in the message from STDIN. Even if mail is piped correctly and the script executes, this will still occur and the message must be read from STDIN to prevent this

    If things aren't working to your liking, test as follows:

    1. Send an email yourself to the relevant address
    2. Check for any bouncebacks
    3. Check /var/log/exim_mainlog

    If you send a message and you get no bounceback and there is no error in /var/log/exim_mainlog, then the piping is in effect correctly and you then only have to ensure that the relevant PHP script is correctly coded, which would be up to you.

    That really does cover everything.
     
  10. sleddog

    sleddog Active Member

    Joined:
    Jun 13, 2004
    Messages:
    44
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Labrador, Canada
    When piping to a PHP script you will probably need to use a format like this:

    Code:
    | php -q /home/username/script.php
    And perhaps even supply the fully path to the PHP binary, e.g.,

    Code:
    | /usr/local/bin/php -q /home/username/script.php
     
  11. Mejoramos.com

    Mejoramos.com Member

    Joined:
    Feb 11, 2004
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    :)

    Much Thanks to all yours.

    :)

    Now all run perfect!.

    :)

    Only run if line is:

    [ | php -q /home/internet/pp.php ]

    Other line = ERROR.

    THANKS!. :D
     
  12. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    36
    Good to hear that everything is up and running correctly.

    When piping to PHP scripts, I've only ever needed to enter "| /home/username/script.php" without needing any extras so I guess I didn't consider that possibility.

    Hopefully this thread will be useful to others.
     
  13. griz

    griz Well-Known Member

    Joined:
    Dec 29, 2001
    Messages:
    47
    Likes Received:
    0
    Trophy Points:
    6
    Great thread!

    1 question, though.

    When piping to a script, is it possible to keep the email from also being delivered to the actual mailbox?

    I know that the obvious answer is to delete the email address...but that won't work for what I'm trying to do.

    Anyone know if it's possible?

    Thanks!

    Larry
     
Loading...

Share This Page