ready to do the imap part
This commit is contained in:
parent
c557bf0bfd
commit
cb1ecf6b6e
2 changed files with 15 additions and 12 deletions
|
@ -80,7 +80,7 @@ class Mail_Handler{
|
|||
|
||||
//creates child process
|
||||
$pid = self::mail_fork();
|
||||
$pidfile = '/tmp/ams_cron_email_pid';
|
||||
$pidfile = '/tmp/ams_cron_email_pid2';
|
||||
|
||||
//INFO: if $pid =
|
||||
//-1: "Could not fork!\n";
|
||||
|
@ -89,15 +89,14 @@ class Mail_Handler{
|
|||
|
||||
if($pid) {
|
||||
|
||||
// We're the parent process, do nothing!
|
||||
|
||||
// We're the parent process, do nothing!
|
||||
|
||||
} else {
|
||||
//make db connection here because the children have to make the connection.
|
||||
$this->db = new DBLayer("lib");
|
||||
|
||||
//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');
|
||||
|
@ -143,12 +142,13 @@ class Mail_Handler{
|
|||
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);
|
||||
$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);
|
||||
|
||||
for ($i = 1; $i <= $message_count; ++$i) {
|
||||
|
||||
$header = imap_header($mbox, $i);
|
||||
$entire_email = imap_fetchheader($mbox, $i) . imap_body($mbox, $i);
|
||||
$subject = decode_utf8($header->subject);
|
||||
|
@ -156,6 +156,7 @@ class Mail_Handler{
|
|||
$from = $header->from[0]->mailbox . '@' . $header->from[0]->host;
|
||||
$txt = get_part($mbox, $i, "TEXT/PLAIN");
|
||||
$html = get_part($mbox, $i, "TEXT/HTML");
|
||||
|
||||
//return task ID
|
||||
$tid = oms_create_email($from, $subject, $txt, $html, $to, $from);
|
||||
|
||||
|
@ -163,12 +164,14 @@ class Mail_Handler{
|
|||
$file = fopen("$basedir/mail/$tid", 'w');
|
||||
fwrite($file, $entire_email);
|
||||
fclose($file);
|
||||
}
|
||||
}
|
||||
//mark message $i of $mbox for deletion!
|
||||
imap_delete($mbox, $i);
|
||||
}
|
||||
//delete marked messages
|
||||
imap_expunge($mbox);
|
||||
imap_close($mbox);
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,8 +31,8 @@ $cfg['db']['ring']['name'] = 'ring_open';
|
|||
$cfg['db']['ring']['user'] = 'shard';
|
||||
$cfg['db']['ring']['pass'] = '';
|
||||
|
||||
$cfg['mail']['username'] = '123';
|
||||
$cfg['mail']['password'] = '456';
|
||||
$cfg['mail']['username'] = 'amsryzom@gmail.com';
|
||||
$cfg['mail']['password'] = 'lol123bol';
|
||||
$cfg['mail']['host'] = 'test.com';
|
||||
|
||||
// To connect to an IMAP server running on port 143 on the local machine,
|
||||
|
@ -44,8 +44,8 @@ $cfg['mail']['host'] = 'test.com';
|
|||
// $mbox = imap_open ("{localhost:995/pop3/ssl/novalidate-cert}", "user_id", "password");
|
||||
// NNTP server on port 119 use: $nntp = imap_open ("{localhost:119/nntp}comp.test", "", "");
|
||||
// To connect to a remote server replace "localhost" with the name or the IP address of the server you want to connect to.
|
||||
$cfg['mail']['server'] = '{localhost:110/pop3/novalidate-cert}INBOX';
|
||||
|
||||
//$cfg['mail']['server'] = '{localhost:110/pop3/novalidate-cert}INBOX';
|
||||
$cfg['mail']['server']= '{imap.gmail.com:993/imap/ssl}INBOX'
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// If true= the server will add automatically unknown user in the database
|
||||
// (in nel.user= nel.permission= ring.ring_user and ring.characters
|
||||
|
|
Loading…
Reference in a new issue