From: Joe H. <jo...@ne...> - 2001-09-26 13:32:52
|
You should be able to just put this in the .forward file of the same users' directory. Sometimes in sendmail it is better to put it in /etc/smrsh, or at least put a symbolic link in there for this program. This way, sendmail can run it as a secure shell. If I get time, I'll try this at work today. -----Original Message----- From: Web-Hoster Support Team [mailto:su...@we...]=20 Sent: Wednesday, September 26, 2001 1:49 AM To: Matthew C. Grab; php...@li... Subject: RE: [Phphelpdesk-help] Enter Tickets via Email Great news this has been talked about for a while - any chance of doing a sendmail version? or do we need to look at procmail? Regards Gavin > -----Original Message----- > From: own...@ww... > [mailto:own...@ww...]On Behalf Of Matthew C. Grab > Sent: 26 September 2001 02:30 > To: php...@li... > Cc: php...@li... > Subject: [Phphelpdesk-help] Enter Tickets via Email > > > > Here is a script that allows you to enter tickets to phphelpdesk > via an email. > Assumed is that you have phphelpdesk up and running, and that you > have php > compiled for command line scripts. Also, you need to have qmail running, > and have an email account that can run this forward script. > For example, I have an email account called helpdesk. I have a > .qmail file > which contains the command > > |/home/helpdesk/mail_to_db.php > > Copy this script in, edit the user and the category, put the > .qmail file in > /home/helpdesk, and whenever this user receives email, it will show up > instantly in the support database. > > This will run the command that is needed. > Note that this does not add the email as the user. All email tickets are > added under one account. It would be simple enough to parse out > the user's > email address, and submit it that way, but this is definitely > simpler. It > might be an idea to create multiple category email addresses, and have > emails categorized that way. > Follows is the mail_to_db.php script. > You will need to edit the variables for such things as what user do you > want the email to be added to, what department, company, category, etc.. > > ------------------------------------------ > #!/usr/bin/php -q > <?php > #This connects to your database - put your mysql server, user, & pass here > $link =3D mysql_connect("localhost", "root", "") > or die ("could not connect\n"); > mysql_select_db ("phphelpdesk") > or die ("could not select database\n"); > $fp =3D fopen("./helplog", "a"); > > #This makes it so that all emails sent to this email address show up under > #the same user in PHPHelpdesk > $ctgry =3D "Other"; > $tbl =3D "ticket"; > $usr =3D "admin"; > $dpt =3D "crag"; > $loc =3D "idunno"; > $nowtime =3D date('Y-m-d H:i:s'); > $priority =3D "1"; > $e_stat =3D "REGISTERED"; > $e_des =3D "Ticket Assigned"; > #Read the entire email, including headers. It is being passed to stdin. > #The last 2 lines carve out only the message body, and trim leading and > #trailing whitespaces. > $fd =3D fopen("php://stdin","r"); > while (!feof($fd)) { > $data =3D fgets($fd, 4096); > $testdata =3D "$testdata$data"; > } > $body =3D strstr($testdata, "\n\n"); > $body =3D trim ($body); > #This builds the query that adds the ticket to the ticket table. > $qry =3D "INSERT INTO $tbl SET t_category=3D'$ctgry', = t_detail=3D'$body', > t_user=3D'$usr', t_priority=3D'$priority', = t_timestamp_opened=3D'$nowtime', > t_department=3D'$dpt', t_location=3D'$loc', t_summary=3D'$UFLINE'"; > $testresult =3D fwrite ($fp, $qry); > $testresult =3D fwrite ($fp, "\n"); > #This executes the query that adds the ticket to the ticket table. > $result =3D mysql_query ($qry) > or die ("Query Failed\n"); > #This saves the Ticket ID created. It is needed to create an > Authorize Event. > $t_id =3D mysql_insert_id ($link); > # or die ("Query Tid Failed\n"); > $testresult =3D fwrite ($fp, $t_id); > $testresult =3D fwrite ($fp, "\n"); > $tbl =3D "events"; > #This builds the query that adds a new Authorize Event to the Event table. > #An Authorize Event in the event table is needed for the ticket > to show up. > $qry2 =3D "INSERT INTO $tbl SET t_id=3D'$t_id', s_user=3D'$usr', > e_assignedto=3D'$usr', e_status=3D'$e_stat', = e_description=3D'$e_des'"; > $testresult =3D fwrite($fp, $qry2); > $testresult =3D fwrite($fp, "\n"); > #This executes the query that adds a new Authorize Event to the > Event table. > $result =3D mysql_query ($qry2) > or die ("Query2 Failed\n"); > #This closes the link to the database. > mysql_close ($link); > ?> > > > _______________________________________________ > Phphelpdesk-help mailing list > Php...@li... > https://lists.sourceforge.net/lists/listinfo/phphelpdesk-help > _______________________________________________ Phphelpdesk-help mailing list Php...@li... https://lists.sourceforge.net/lists/listinfo/phphelpdesk-help |