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.

action on email receiving

Discussion in 'E-mail Discussions' started by s_2_s, Feb 6, 2008.

  1. s_2_s

    s_2_s Well-Known Member

    Joined:
    Aug 9, 2004
    Messages:
    215
    Likes Received:
    0
    Trophy Points:
    16
  2. s_2_s

    s_2_s Well-Known Member

    Joined:
    Aug 9, 2004
    Messages:
    215
    Likes Received:
    0
    Trophy Points:
    16
    any ideas ?
     
  3. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    You could set up a forwarder to send a copy of the email to your SMS email while continuing to deliver the message to notify@
     
  4. s_2_s

    s_2_s Well-Known Member

    Joined:
    Aug 9, 2004
    Messages:
    215
    Likes Received:
    0
    Trophy Points:
    16
    thanks for your reply
    i dont have an email to sms functionality like number@smsprovider.com
    as i told you i want to excute a script or call a url once an email message is received from and i can have the subject and body as strings
     
  5. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    In that case, just set up a forwarder but when asked for where you want the email to forward to, select the option to pipe it to a program and provide the path to your script (public_html/smsnotify.php given your previous example). Your PHP script would need to handle the email appropriately to route it to your SMS. This actually isn't a very difficult thing to do in PHP, but it can take some research if you have never done it before.
     
  6. s_2_s

    s_2_s Well-Known Member

    Joined:
    Aug 9, 2004
    Messages:
    215
    Likes Received:
    0
    Trophy Points:
    16
    thank you
    didn't notice that new feature in cpanel
    i only need to know how to pass the subject and body to the php file that i will assign ?
    for example if i put this into the pipe to field

    /home/user/do.php

    how can my do.php retrive the from name , from address , subject , to , body

    are they passed in variables ? if so then what are them ?
     
    #6 s_2_s, Feb 6, 2008
    Last edited: Feb 6, 2008
  7. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator

    When you pipe email to a PHP script, you will be getting the raw email in STDIN. Here's a quick PHP shell script I threw together just to pipe emails to a file:

    PHP:
    #!/usr/bin/php -q
    <?php

    // starting simple

    $input file_get_contents("php://stdin");
    $fp fopen("/home/username/public_html/maillog.log","w");

    fwrite($fp$input);

    fclose($fp);


    ?>
    You can replace username with your username.

    I know some people don't like dealing with email piping because there's much string manipulation to be done. For example, here's the raw input you would expect to receive from a sample mail sent to your script (where pipe@mydomain.com was the address the message was sent to, message was sent from another email account on the same server):

    Code:
    From from-address@theirDomain.com Fri Jul 06 11:36:37 2007
    Received: from [127.0.0.1] (helo=localhost)
    	by server.host.name with esmtpa (Exim 4.66)
    	(envelope-from <from-address@theirDomain.com>)
    	id 1I6qnN-00013q-M8
    	for pipe@mydomain.com; Fri, 06 Jul 2007 11:36:37 -0500
    Received: from 192.168.40.200 ([192.168.40.200]) by server.host.name
    	(Horde MIME library) with HTTP; Fri, 06 Jul 2007 11:36:37 -0500
    Message-ID: <20070706113637.694eg0iisgo48sok@server.host.name>
    Date: Fri, 06 Jul 2007 11:36:37 -0500
    From: from-address@theirDomain.com
    To: pipe@mydomain.com
    Subject: This is my subject line!
    MIME-Version: 1.0
    Content-Type: text/plain;
    	charset=ISO-8859-1;
    	DelSp="Yes";
    	format="flowed"
    Content-Disposition: inline
    Content-Transfer-Encoding: 7bit
    User-Agent: Internet Messaging Program (IMP) H3 (4.1.3)
    
    Body
    Body Line #2
    Body Line #3
    
    
    Actual emails from other servers will likely have more headers, but you get the basic idea :)
     
  8. The Reckoning

    The Reckoning Registered

    Joined:
    Mar 3, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    I tried using this with my server, and whenever I send an email to 'xxx@domain.com,' I get this error:
    I masked folders and the domain for certain reasons. Anyone know why I'm getting this error? This is on an add-on domain. Thanks!
     
  9. DrBurkstrom

    DrBurkstrom Registered

    Joined:
    Apr 10, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    TheReckoning, I had this exact same problem, I'm not saying this is the right way to fix it, but it did fix it.

    When you set up the forwarding in cPanel, try typing "php /usr/home/username/public_html/script.php" into the field where it asks for the program to pipe to. cPanel says not to do this but it seems to work.

    When you click "Add Forwarder" cPanel tells you the program needs fixing, click fix and it sorts it right out.

    As I say, perhaps not the strictly correct way to get it working, that's what I came here for, but a combination of posts on this forum and guesswork sorted me out!
     
    #9 DrBurkstrom, Apr 10, 2008
    Last edited: Apr 10, 2008
  10. subjectx

    subjectx Member

    Joined:
    Jun 11, 2008
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    I get same problem as TheReckoning.

    And solution above me doesnt work out..

    Any other suggestions?
     
  11. subjectx

    subjectx Member

    Joined:
    Jun 11, 2008
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    after some lucky incident, i deleted empty new line feed between hashbang and <? start of my script and it started working ok, without and strange error mails.

    I deleted all of whitespaces after ?> too..
     
Loading...

Share This Page