Mail function to check any mail box?

Post modules, themes or any other code you want to share with the community.

Moderator: Developers

Posts: 11
Joined: Fri Aug 12, 2011 8:45 am
Location: Germany

Mail function to check any mail box?

Postby sven-teichmann » Thu Sep 15, 2011 4:41 pm

Is there any mail function in Group Office with which it is possible to check any mail box?

I've found this function in Group Office, but with this one it is only possible to check the mail box of a Group Office user, I think:

Code: Select all

    	public static function check_mail(&$response){
		require_once ($GO_MODULES->modules['email']['class_path']."");
		$imap = new cached_imap();
		$email = new email();
		$email2 = new email();

		$count = $email->get_accounts($GO_SECURITY->user_id);
		while($email->next_record()) {
				$account = $imap->open_account($email->f('id'), 'INBOX', false);			

				if($account) {
					$inbox = $email2->get_folder($email->f('id'), 'INBOX');

					$unseen =  $imap->get_unseen();

					$response['email_status'][$inbox['id']]['unseen'] = $unseen['count'];
					$response['email_status'][$inbox['id']]['messages'] = $imap->selected_mailbox['messages'];
			catch(Exception $e){
I need such a function for a new module I'm writing at the moment. A module with which it is possible to create orders in Billing module from mails. If there is not already such a function in Group Office, I have to write my own.
Sven Teichmann
User avatar
Group-Office Developer
Group-Office Developer
Posts: 86
Joined: Mon May 10, 2010 3:47 pm
Location: Den Bosch, Netherlands

Re: Mail function to check any mail box?

Postby WilmarVB » Fri Oct 21, 2011 2:52 pm

Hello Sven,

Sounds like a sweet plan. Did you also consider getting some form of feedback on the status of the order creation (e.g., success or error messages)?

As for your question: instantiations of the class declared in classes/mail/ can do a lot of the handling of incoming mails. You might want to tinker with $imap->connect, $imap->get_uidnext() and the methods starting with "get_message". You also need to 'require' the Group-Office.php in your script so that the necessary Group-Office configuration object can be used by your imap class.

Suggestion: have a cron job run your script.

Good luck!
Kind regards,

Who is online

Users browsing this forum: No registered users and 2 guests