How to integrate my email accounts in codeigniter php

时间:2017-08-05 10:24:17

标签: php codeigniter email

I want to integrate my (G-Mail, Yahoo, Hotmail) accounts in my codeigniter project.

So I search and found POP3 and IMAP for my solution. Its working for G-Mail only But its not working for Yahoo and Hotmail.

I search a lot and try my best but all in vain. I download and include pop3 library in my project also from Github

Note: I want to add in my codeigniter project but now I am working for testing purpose in simple php file and all code is written in same file (When I want to test yahoo mail or hotmail code I comment other mail codes) on localhost

include "php-mail/class.pop3.php";

Here is G-Mail Code

$gmail_pop3 = new POP3;
$gmail_host = $gmail_pop3->hostname = "pop.gmail.com";
$gmail_port = $gmail_pop3->port = 995;
$gmail_tsl = $gmail_pop3->tls = 1;
$gmail_path = "{" . $gmail_host . ":" . $gmail_port ."/pop3/ssl/novalidate-cert}INBOX";
$gmail_user = "testing.php24@gmail.com";
$gmail_password = "deemis24";

$gmail_inbox = imap_open($gmail_path, $gmail_user, $gmail_password) or die('Cannot connect to Gmail: ' . imap_last_error());

$gmail_emails = imap_search($gmail_inbox,'ALL',SE_UID, "UTF-8");

echo "<pre>";
    print_r($gmail_emails);
echo "</pre>";

Its working perfectly for me and give me results

But Yahoo and Hotmail Got issues

Here is for Yahoo code

$yahoo_pop3 = new POP3;
$yahoo_host = $yahoo_pop3->hostname = "pop.mail.yahoo.com";
$yahoo_port = $yahoo_pop3->port = 995;
$yahoo_tsl = $yahoo_pop3->tls = 1;
$yahoo_path = "{" . $yahoo_host . ":" . $yahoo_port ."/pop3/ssl/novalidate-cert}INBOX";
$yahoo_user = "testing_php24@yahoo.com";
$yahoo_password = "deemis24";

$yahoo_inbox = imap_open($yahoo_path, $yahoo_user, $yahoo_password) or die('Cannot connect to Yahoo: ' . imap_last_error());

$yahoo_emails = imap_search($yahoo_inbox,'ALL',SE_UID, "UTF-8");

echo "<pre>";
print_r($yahoo_inbox);
echo "</pre>";

imap_expunge($yahoo_inbox);
imap_close($yahoo_inbox);

Yahoo mail error

Warning: imap_open(): Couldn't open stream {pop.mail.yahoo.com:995/pop3/ssl/novalidate-cert}INBOX in E:\xampp\htdocs\php-mail\pop3.php on line 90
Cannot connect to Yahoo: POP3 connection broken in response
Notice: Unknown: POP3 connection broken in response (errflg=1) in Unknown on line 0

Here is for Hotmail code

$hotmail_pop3 = new POP3;
$hotmail_host = $hotmail_pop3->hostname = "pop3.live.com";
$hotmail_port = $hotmail_pop3->port = 995;
$hotmail_tsl = $hotmail_pop3->tls = 1;
$hotmail_path = "{" . $hotmail_host . ":" . $hotmail_port ."/pop3/ssl/novalidate-cert}INBOX";
$hotmail_user = "testing_php24@hotmail.com";
$hotmail_password = "deemis24";

$hotmail_inbox = imap_open($hotmail_path, $hotmail_user, $hotmail_password) or die('Cannot connect to hotmail: ' . imap_last_error());

$hotmail_emails = imap_search($hotmail_inbox,'ALL',SE_UID, "UTF-8");

echo "<pre>";
print_r($hotmail_inbox);
echo "</pre>";

imap_expunge($hotmail_inbox);
imap_close($hotmail_inbox);

Hotmail error

Warning: imap_open(): Couldn't open stream {pop3.live.com:995/pop3/ssl/novalidate-cert}INBOX in E:\xampp\htdocs\php-mail\pop3.php on line 114
Cannot connect to hotmail: Too many login failures
Notice: Unknown: Logon failure: unknown user name or bad password. (errflg=1) in Unknown on line 0

Notice: Unknown: Logon failure: unknown user name or bad password. (errflg=1) in Unknown on line 0

Notice: Unknown: Logon failure: unknown user name or bad password. (errflg=1) in Unknown on line 0

Notice: Unknown: Too many login failures (errflg=2) in Unknown on line 0

I got very confused what to do. I search a lot but nothing any helpful thing. So please guide me complete and give me working solution for codeigniter

Hope you understand my question.

0 个答案:

没有答案