web/website/integrations/osticket/configure-mail.php
unimatrixgit 77cdf19faa Checkpoint Alpha 1.0.0.3 graphical menus and moderation evidence
Preserve the current Alpha source and artwork snapshot. See handoff/alpha-1.0.0.3 for actual deployed hashes, checks, staged follow-ups and the production pause. This checkpoint does not claim every source feature is deployed.
2026-11-02 00:05:34 +01:00

7 lines
1.6 KiB
PHP

<?php
if(PHP_SAPI!=='cli')exit(1);chdir('/home/dunerealms/apps/integrations/osticket');$_SERVER['REQUEST_METHOD']='CLI';$_SERVER['SCRIPT_NAME']='/api/cron.php';require './main.inc.php';
$target=$argv[1]??'support@dunerealms.com';if(!in_array($target,['support@dunerealms.com','unimatrix@dunerealms.com','legal@dunerealms.com','sales@dunerealms.com'],true))exit(1);
$data=json_decode(file_get_contents('/root/osticket-mail-connection.json'),true);$entry=null;foreach(($data['mailboxes']??[$data])as$m)if(($m['email']??'')===$target)$entry=$m;if(!$entry||empty($entry['password']))throw new Exception('Support credentials unavailable');
$email=Email::lookup(['email'=>$target]);if(!$email||$email->getEmail()!==$target)throw new Exception('Support identity mismatch');
foreach(['mailbox','smtp']as$type){$a=$type==='mailbox'?$email->getMailBoxAccount():$email->getSmtpAccount();$spec=$entry[$type==='mailbox'?'imap':'smtp']??$data[$type==='mailbox'?'imap':'smtp'];$a->host=$spec['host'];$a->port=(int)$spec['port'];$a->protocol=$type==='mailbox'?'IMAP':'SMTP';$a->active=0;if($type==='mailbox'){$a->folder='DuneRealmsTickets';$a->fetchfreq=5;$a->fetchmax=20;$a->postfetch='nothing';}else $a->allow_spoofing=0;if(!$a->save())throw new Exception('Could not save '.$type);$errors=[];if(!$a->updateCredentials('basic',['username'=>$entry['username'],'passwd'=>$entry['password']],$errors)){echo $type.' authentication failed: '.json_encode($errors).PHP_EOL;exit(1);}if($type==='smtp'){$a->active=1;$a->save();}echo $type.' authentication verified and credentials encrypted'.PHP_EOL;}
echo 'SMTP enabled; inbound fetching held pending account intake policy.'.PHP_EOL;