From: Matt G. <ma...@ma...> - 2001-09-26 13:59:31
|
Basically this is a script written in PHP. There are 2 variables, what email program are you running, and what scripting language are you using. This is the PHP answer to the equation. Mysql actually comes with a PERL script for adding email to a database, but it is coded with the email program part of the equation as sendmail, not qmail. That script is called mail_to_db.pl. My script could be adapted to that script, so basically 80% of the work is done - if you want sendmail, PERL, mysql, PHP, and phphelpdesk. At 06:51 AM 9/26/2001 -0700, you wrote: >You should just be able to put "|/home/helpdesk/mail_to_db.php", without >the quotes, into /home/username/.forward. Now Sendmail has be be able >to run that command. And sometimes you need to put that command >"mail_to_db.php" into /etc/smrsh so that sendmail knows that it is a >secure command that it should be able to run. PHP has to be compiled >with command line arguments. I don't know the flag for this. But it >doesn't have to even be a PHP script. You could do PERL, python, or >many other scripting languages. > >-----Original Message----- >From: Matt Grab [mailto:ma...@ma...] >Sent: Wednesday, September 26, 2001 6:48 AM >To: Joe Hoot >Subject: RE: [Phphelpdesk-help] Enter Tickets via Email > >As far as I can tell, the only differences are these: >1 - how do you forward an email to a script in sendmail >2 - how does sendmail make the email available to the script process - >ie. >is it on stdin, or is it an environment variable, or is it a command >line >argument > >At 06:32 AM 9/26/2001 -0700, you wrote: > >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...] > >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 = mysql_connect("localhost", "root", "") > > > or die ("could not connect\n"); > > > mysql_select_db ("phphelpdesk") > > > or die ("could not select database\n"); > > > $fp = fopen("./helplog", "a"); > > > > > > #This makes it so that all emails sent to this email address show up > >under > > > #the same user in PHPHelpdesk > > > $ctgry = "Other"; > > > $tbl = "ticket"; > > > $usr = "admin"; > > > $dpt = "crag"; > > > $loc = "idunno"; > > > $nowtime = date('Y-m-d H:i:s'); > > > $priority = "1"; > > > $e_stat = "REGISTERED"; > > > $e_des = "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 = fopen("php://stdin","r"); > > > while (!feof($fd)) { > > > $data = fgets($fd, 4096); > > > $testdata = "$testdata$data"; > > > } > > > $body = strstr($testdata, "\n\n"); > > > $body = trim ($body); > > > #This builds the query that adds the ticket to the ticket table. > > > $qry = "INSERT INTO $tbl SET t_category='$ctgry', t_detail='$body', > > > t_user='$usr', t_priority='$priority', >t_timestamp_opened='$nowtime', > > > t_department='$dpt', t_location='$loc', t_summary='$UFLINE'"; > > > $testresult = fwrite ($fp, $qry); > > > $testresult = fwrite ($fp, "\n"); > > > #This executes the query that adds the ticket to the ticket table. > > > $result = mysql_query ($qry) > > > or die ("Query Failed\n"); > > > #This saves the Ticket ID created. It is needed to create an > > > Authorize Event. > > > $t_id = mysql_insert_id ($link); > > > # or die ("Query Tid Failed\n"); > > > $testresult = fwrite ($fp, $t_id); > > > $testresult = fwrite ($fp, "\n"); > > > $tbl = "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 = "INSERT INTO $tbl SET t_id='$t_id', s_user='$usr', > > > e_assignedto='$usr', e_status='$e_stat', e_description='$e_des'"; > > > $testresult = fwrite($fp, $qry2); > > > $testresult = fwrite($fp, "\n"); > > > #This executes the query that adds a new Authorize Event to the > > > Event table. > > > $result = 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 > > > >_______________________________________________ > >Phphelpdesk-help mailing list > >Php...@li... > >https://lists.sourceforge.net/lists/listinfo/phphelpdesk-help |