To fetch gmail mails, i am using below code. it is working fine in local, but i am getting error in server like :
Warning: imap_open(): Couldn't open stream {imap.googlemail.com:993/imap/ssl/novalidate-cert}INBOX in C:\xampp\htdocs\criticaloglive\email_real.php on line 10
Cannot connect to Gmail: Too many login failures
Here's my code :
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$server = '{imap.googlemail.com:993/imap/ssl/novalidate-cert}INBOX';
$username = 'mymail#gmail.com';
$password = 'mypassword';
// try to connect
$inbox = imap_open($server,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
Use the $hostname instead of $server. also try with not secure imap with port 143
$inbox = imap_open($hostname,$username,$password) ;
this code works for me.
Related
Screenshot
Connection timed out when tried to fetch emails from the cpanel roundcube.
All credentials are perfect and hostname and server also working fine.
$hostname = '{mail.server.com:993/novalidate-cert/imap/ssl}';
$username = 'username';
$password = 'password';
$stream = imap_open($hostname, $username, $password) or die('Cannot connect: ' . imap_last_error());
print_r(imap_errors());
Can anyone help please?
Thank you
I am trying to access to office365 inbox, but I am getting this message
PHP Warning: imap_open(): Couldn't open stream {outlook.office365.com:993/imap/ssl}
Here is my code
$hostname = '{outlook.office365.com:993/imap/ssl/novalidate-cert}';
$username = '*****';
$password = '*****';
$fp = fopen('cox_cash [30 40].txt', 'w+');
if (!$fp) die("Impossible d'ouvrir le fichier");
/* try to connect */
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to : ' . imap_last_error());
For me, the issue was not having the imap library for php. Try using function_exists('imap_open') to check if you actually have the library. function_exists() returns true if your php has the function, false otherwise. Simple if statement with echos should do the trick.
I have working mssql connecting codes and them working in my another company php host but dont work when i moved new host. All codes same i dont know why connect from new host ? In new host using cpanel and php ( Hostgator ) and im looking php.ini in cpanel mssql settings looking good. my codes below under.
$usernameb ="myuser";
$passwordb = "mypass";
$databaseb = "mydb";
$host ="myhostip"
$connection = mssql_connect($host, $usernameb, $passwordb);
if (!$connection) { die('Not connected : ' . mssql_get_last_message());}
$db_selected = mssql_select_db($databaseb, $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mssql_get_last_message());
} else{
}
And gives that error on my new hosting
Warning: mssql_connect(): Unable to connect to server: ip here in
Any idea ?
I'd like to open Gmail mailbox. But the following error was occurred.
Notice: Unknown: Can't open mailbox
{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX: invalid remote
specification (errflg=2) in Unknown on line 0
Below is my code.
$mailserver = "{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX";
$username = "XXXXXX#gmail.com";
$password = "YYYYYY";
$mailbox = #imap_open($mailserver, $username, $password);
var_dump($mailbox);exit; // false
So could you tell me the solution?
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = '******#gmail.com';
$password = '******';
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
$emails = imap_search($inbox,'SUBJECT "string"');
$mail_ids = array();
if($emails) {
echo count($emails);
}
This code gives output of 309. But, when I search in gmail, using same keyword, I get 344 results.
Any idea where data is lost or where I am wrong?
$emails = imap_search($inbox,'BODY "string" SUBJECT "string"');
found more results as per #arnt's comment. Thanks :)