mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-17 13:01:42 +00:00
sending mail with supportgroup ID is possible
--HG-- branch : quitta-gsoc-2013
This commit is contained in:
parent
fb7254c018
commit
8262febe32
5 changed files with 36 additions and 34 deletions
|
@ -58,11 +58,14 @@ class Mail_Handler{
|
|||
//the main function
|
||||
function cron() {
|
||||
global $cfg;
|
||||
$inbox_username = $cfg['mail']['username'];
|
||||
$default_groupemail = $cfg['mail']['default_groupemail'];
|
||||
$default_groupname = $cfg['mail']['default_groupname'];
|
||||
/*$inbox_username = $cfg['mail']['username'];
|
||||
$inbox_password = $cfg['mail']['password'];
|
||||
$inbox_host = $cfg['mail']['host'];
|
||||
$oms_reply_to = "Ryzom Ticketing Support <ticketing@".$inbox_host.">";
|
||||
global $MAIL_DIR;
|
||||
global $MAIL_DIR;*/
|
||||
|
||||
|
||||
// Deliver new mail
|
||||
echo("mail cron\n");
|
||||
|
@ -70,15 +73,14 @@ class Mail_Handler{
|
|||
//creates child process
|
||||
$pid = self::mail_fork();
|
||||
$pidfile = '/tmp/ams_cron_email_pid';
|
||||
|
||||
//INFO: if $pid =
|
||||
//-1: "Could not fork!\n";
|
||||
// 0: "In child!\n";
|
||||
//>0: "In parent!\n";
|
||||
|
||||
if($pid) {
|
||||
|
||||
// We're the parent process, do nothing!
|
||||
//INFO: if $pid =
|
||||
//-1: "Could not fork!\n";
|
||||
// 0: "In child!\n";
|
||||
//>0: "In parent!\n";
|
||||
|
||||
} else {
|
||||
//make db connection here because the children have to make the connection.
|
||||
|
@ -86,6 +88,7 @@ class Mail_Handler{
|
|||
|
||||
//if $pidfile doesn't exist yet, then start sending the mails that are in the db.
|
||||
if(!file_exists($pidfile)) {
|
||||
|
||||
//create the file and write the child processes id in it!
|
||||
$pid = getmypid();
|
||||
$file = fopen($pidfile, 'w');
|
||||
|
@ -106,18 +109,16 @@ class Mail_Handler{
|
|||
$email['Recipient'] = Ticket_User::get_email_by_user_id($email['UserId']);
|
||||
}
|
||||
|
||||
//create sending email adres based on the $sender id
|
||||
if($email['Sender'] != 0) {
|
||||
$username = Ticket_User::get_username_from_id($email['Sender']);
|
||||
$from = "$username <$username@$inbox_host>";
|
||||
//create sending email adres based on the $sender id which refers to the department id
|
||||
if($email['Sender'] == NULL) {
|
||||
$from = $default_groupname ." <".$default_groupemail.">";
|
||||
} else {
|
||||
$from = $oms_reply_to;
|
||||
$group = Support_Group::getGroup($email['Sender']);
|
||||
$from = $group->getName()." <".$group->getGroupEmail().">";
|
||||
}
|
||||
|
||||
$headers = "From: $from\r\n" . "Message-ID: " . $message_id ;
|
||||
print("recip: " . $email['Recipient']);
|
||||
print("subj: " .$email['Subject']);
|
||||
print("body: " . $email['Body']);
|
||||
print("headers: " . $headers);
|
||||
|
||||
if(mail($email['Recipient'], $email['Subject'], $email['Body'], $headers)) {
|
||||
$status = "DELIVERED";
|
||||
echo("Emailed {$email['Recipient']}\n");
|
||||
|
@ -127,13 +128,12 @@ class Mail_Handler{
|
|||
}
|
||||
//change the status of the emails.
|
||||
$this->db->execute('update email set Status = ?, MessageId = ?, Attempts = Attempts + 1 where MailId = ?', array($status, $message_id, $email['MailId']));
|
||||
//db_exec('update email set status = ?, message_id = ?, attempts = attempts + 1 where id_email = ?', array($status, $message_id, $email['id_email']));
|
||||
|
||||
}
|
||||
unlink($pidfile);
|
||||
}
|
||||
// Check mail
|
||||
|
||||
//$mailbox = imap_open("{localhost:110/pop3/novalidate-cert}INBOX", $inbox_username, $inbox_password);
|
||||
$mbox = imap_open($cfg['mail']['server'], $inbox_username, $inbox_password) or die('Cannot connect to mail server: ' . imap_last_error());
|
||||
$message_count = imap_num_msg($mbox);
|
||||
|
||||
|
|
|
@ -31,9 +31,11 @@ $cfg['db']['ring']['name'] = 'ring_open';
|
|||
$cfg['db']['ring']['user'] = 'shard';
|
||||
$cfg['db']['ring']['pass'] = '';
|
||||
|
||||
$cfg['mail']['default_groupemail'] = 'support@ryzomcore.com';
|
||||
$cfg['mail']['default_groupname'] = 'Ryzomcore Support';
|
||||
$cfg['mail']['username'] = 'amsryzom@gmail.com';
|
||||
$cfg['mail']['password'] = 'lol123bol';
|
||||
$cfg['mail']['host'] = 'ryzomcore.com';
|
||||
//$cfg['mail']['host'] = 'ryzomcore.com';
|
||||
|
||||
// To connect to an IMAP server running on port 143 on the local machine,
|
||||
// do the following: $mbox = imap_open("{localhost:143}INBOX", "user_id", "password");
|
||||
|
|
|
@ -353,19 +353,14 @@
|
|||
`Body` VARCHAR(400) NULL ,
|
||||
`Status` VARCHAR(45) NULL ,
|
||||
`Attempts` VARCHAR(45) NULL DEFAULT 0 ,
|
||||
`Sender` INT(10) UNSIGNED NOT NULL ,
|
||||
`UserId` INT(10) UNSIGNED NOT NULL ,
|
||||
`MessageId` VARCHAR(45) NOT NULL ,
|
||||
`MessageId` VARCHAR(45) NULL ,
|
||||
`TicketId` INT UNSIGNED NOT NULL ,
|
||||
`Sender` INT(10) UNSIGNED NULL ,
|
||||
PRIMARY KEY (`MailId`) ,
|
||||
INDEX `fk_email_ticket_user1` (`Sender` ASC) ,
|
||||
INDEX `fk_email_ticket_user2` (`UserId` ASC) ,
|
||||
INDEX `fk_email_ticket1` (`TicketId` ASC) ,
|
||||
CONSTRAINT `fk_email_ticket_user1`
|
||||
FOREIGN KEY (`Sender` )
|
||||
REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`TUserId` )
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION,
|
||||
INDEX `fk_email_support_group1` (`Sender` ASC) ,
|
||||
CONSTRAINT `fk_email_ticket_user2`
|
||||
FOREIGN KEY (`UserId` )
|
||||
REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`TUserId` )
|
||||
|
@ -375,6 +370,11 @@
|
|||
FOREIGN KEY (`TicketId` )
|
||||
REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` )
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION,
|
||||
CONSTRAINT `fk_email_support_group1`
|
||||
FOREIGN KEY (`Sender` )
|
||||
REFERENCES `" . $cfg['db']['lib']['name'] ."`.`support_group` (`SGroupId` )
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION)
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
|
|
@ -309,19 +309,14 @@ CREATE TABLE IF NOT EXISTS `mydb`.`email` (
|
|||
`Body` VARCHAR(400) NULL ,
|
||||
`Status` VARCHAR(45) NULL ,
|
||||
`Attempts` VARCHAR(45) NULL DEFAULT 0 ,
|
||||
`Sender` INT(10) UNSIGNED NOT NULL ,
|
||||
`UserId` INT(10) UNSIGNED NOT NULL ,
|
||||
`MessageId` VARCHAR(45) NOT NULL ,
|
||||
`TicketId` INT UNSIGNED NOT NULL ,
|
||||
`Sender` INT(10) UNSIGNED NULL ,
|
||||
PRIMARY KEY (`MailId`) ,
|
||||
INDEX `fk_email_ticket_user1` (`Sender` ASC) ,
|
||||
INDEX `fk_email_ticket_user2` (`UserId` ASC) ,
|
||||
INDEX `fk_email_ticket1` (`TicketId` ASC) ,
|
||||
CONSTRAINT `fk_email_ticket_user1`
|
||||
FOREIGN KEY (`Sender` )
|
||||
REFERENCES `mydb`.`ticket_user` (`TUserId` )
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION,
|
||||
INDEX `fk_email_support_group1` (`Sender` ASC) ,
|
||||
CONSTRAINT `fk_email_ticket_user2`
|
||||
FOREIGN KEY (`UserId` )
|
||||
REFERENCES `mydb`.`ticket_user` (`TUserId` )
|
||||
|
@ -331,6 +326,11 @@ CREATE TABLE IF NOT EXISTS `mydb`.`email` (
|
|||
FOREIGN KEY (`TicketId` )
|
||||
REFERENCES `mydb`.`ticket` (`TId` )
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION,
|
||||
CONSTRAINT `fk_email_support_group1`
|
||||
FOREIGN KEY (`Sender` )
|
||||
REFERENCES `mydb`.`support_group` (`SGroupId` )
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION)
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue