kapcom01 As a last resort, I am thinking of making a script to read the new emails and close the ticket by changing the status_id on the db.
I just want to report that I did make that script. It is not tested in production yet, but with test tickets works fine.
On Debian server:
apt install fdm procmail
create file /root/reply-close-script/fdm.conf:
set lock-file "/root/reply-close-script/fdm.lock"
set queue-high 1
action "osticket-close" {
mbox "/root/reply-close-script/INBOX.backup"
write "/root/reply-close-script/mail.tmp"
exec "/root/reply-close-script/reply-close.sh >> /root/reply-close-script/reply-close.log"
exec "rm /root/reply-close-script/mail.tmp"
}
account "osticket@mydomain.com" imaps server "mail.mydomain.com"
user "osticket@mydomain.com" pass "mypassword" new-only keep
match all action "osticket-close"
create file /root/reply-close-script/reply-close.sh:
#!/bin/bash
exit_code=1
dbname="osTicket"
mariadbconf="/root/reply-close-script/mariadb.conf"
mailfile="/root/reply-close-script/mail.tmp"
# search for ticket number in Subject
ticket_number=$(formail -c -x Subject < $mailfile | php -r 'echo iconv_mime_decode(stream_get_contents(STDIN),1,"utf-8");' | perl -n -e'/#(.*)$/ && print $1');
# if found:
if [[ -n $ticket_number ]]
then
# close the ticket in db
echo "[$(date --iso-8601=seconds)] closing ticket #$ticket_number"
sqlquery="UPDATE \`ost_ticket\` SET \`status_id\`=3, \`isanswered\`=1 WHERE \`number\`=\"$ticket_number\""
/usr/bin/mysql --defaults-extra-file=$mariadbconf $dbname -sN -e "$sqlquery"
exit_code=0
else
echo "[$(date --iso-8601=seconds)] ticket not found in $mailfile"
fi
exit $exit_code
create file /root/reply-close-script/mariadb.conf:
[client]
user=root
password=mypass
add a job with crontab -e:
*/5 * * * * fdm -v -f /root/reply-close-script/fdm.conf fetch >> /root/reply-close-script/fdm.log 2>&1