Use Imap in wordpress plugin
-
Hi There.
I am trying to retreive emails from my gmail account to get them into my wordpress back end. I created a Wp plugin that includes files from this repository. but when I try it I get errors:
Fatal error: Uncaught exception 'PhpImap\Exception' with message 'Connection error: Can't connect to gmail-imap.l.google.com,993: Connection timed out' in /home/tuthivtg/public_html/wp-content/plugins/airtel-money-online-payement/Mailbox.php:76 Stack trace: #0 /home/tuthivtg/public_html/wp-content/plugins/airtel-money-online-payement/Mailbox.php(67): PhpImap\Mailbox->initImapStream() #1 /home/tuthivtg/public_html/wp-content/plugins/airtel-money-online-payement/Mailbox.php(168): PhpImap\Mailbox->getImapStream() #2 /home/tuthivtg/public_html/wp-content/plugins/airtel-money-online-payement/index.php(23): PhpImap\Mailbox->searchMailbox('ALL') #3 [internal function]: airtel_money_ops_output_content('') #4 /home/tuthivtg/public_html/wp-includes/plugin.php(525): call_user_func_array('airtel_money_op...', Array) #5 /home/tuthivtg/public_html/wp-admin/admin.php(236): do_action('plugins_page_ai...') #6 /home/tuthivtg/public_html/wp-admin/plugins.php(10): require_once('/home/tuthivtg/...') #7 {main} thrown in /home/tuthivtg/public_html/wp-content/plugins/airtel-money-online-payement/Mailbox.php on line 76 Notice: Unknown: Can't connect to gmail-imap.l.google.com,993: Connection timed out (errflg=1) in Unknown on line 0 Notice: Unknown: Can't connect to gmail-imap.l.google.com,993: Connection timed out (errflg=2) in Unknown on line 0
Is there someone who has done such thing before? If yes am using the right approach? here is my pmugin code :
`<?php
/**
* Plugin Name: Plugin System
* Description: A brief description about your plugin.
* Version: 1.0 or whatever version of the plugin (pretty self explanatory)
* Author: Mayombo Kamba-bilola Ted Valery
* Author URI: Author’s website
* License: Private
*/
include( plugin_dir_path( __FILE__ ) . ‘__autoload.php’);
include( plugin_dir_path( __FILE__ ) . ‘Mailbox.php’);
include( plugin_dir_path( __FILE__ ) . ‘IncomingMail.php’);function my_special_plg_ops_output_content(){
// 4. argument is the directory into which attachments are to be saved:
$mailbox = new PhpImap\Mailbox(‘{imap.gmail.com:993/imap/ssl}INBOX’, ‘[email protected]’, ‘******’, __DIR__);// Read all messaged into an array:
$mailsIds = $mailbox->searchMailbox(‘ALL’);
if(!$mailsIds) {
die(‘Mailbox is empty’);
}// Get the first message and save its attachment(s) to disk:
$mail = $mailbox->getMail($mailsIds[0]);
var_dump($mail);
echo “\n\n\n\n\n”;
var_dump($mail->getAttachments());
}
add_action(‘admin_menu’, ‘my_special_plg_ops_menu’);function my_special_plg_ops_menu() {
add_plugins_page(‘Airtel Money OPS Page’, ‘Airtel Money OPS’, ‘read’, ‘my_special_plg_ops’, ‘my_special_plg_ops_output_content’);
}`Any help would be really appriciated.
Kind Regards
- The topic ‘Use Imap in wordpress plugin’ is closed to new replies.