Last active
August 29, 2015 14:06
-
-
Save peterjaap/b86ff6cbfa9199f94ade to your computer and use it in GitHub Desktop.
Create Gmail forwarders for Codebase tickets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
This little script creates an XML file for you to import in your Gmail account. | |
It creates forwarders to automatically create tickets in Codebase with an | |
easy to remember emailformat like tickets-<projectname>@company.com. | |
For more information see http://support.codebasehq.com/articles/tickets/submitting-a-ticket-via-e-mail | |
and http://gmailblog.blogspot.nl/2009/03/new-in-labs-filter-importexport.html | |
*/ | |
$projects = array( | |
array("Project"=>"projectname","Email"=>"newticket+randomcode@email.codebasehq.com"), | |
); | |
$xml = "<?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:apps='http://schemas.google.com/apps/2006'> | |
<title>Mail Filters</title> | |
<author> | |
<name>My Name</name> | |
<email>me@company.com</email> | |
</author>"; | |
$template = PHP_EOL . "<entry> | |
<category term='filter'></category> | |
<title>Forward new tickets for PROJECTNAME</title> | |
<content></content> | |
<apps:property name='to' value='tickets-PROJECTNAME@company.com'/> | |
<apps:property name='shouldMarkAsRead' value='true'/> | |
<apps:property name='shouldArchive' value='true'/> | |
<apps:property name='forwardTo' value='EMAILADDRESS'/> | |
<apps:property name='sizeOperator' value='s_sl'/> | |
<apps:property name='sizeUnit' value='s_smb'/> | |
</entry>" . PHP_EOL; | |
foreach($projects as $project) { | |
$entry = $template; | |
$entry = str_replace('PROJECTNAME', $project['Project'], $entry); | |
$entry = str_replace('EMAILADDRESS', $project['Email'], $entry); | |
$xml .= $entry; | |
} | |
$xml .= "</feed>"; | |
echo PHP_EOL . $xml . PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment