My code is working fine when run on windows laptop with XAMPP, but when I try to run same code on linux machine it is giving error.
My code:
<?php
$connect_to = '{imap.gmail.com:993/imap/ssl}INBOX';
$user = 'my gmail address';
$password = 'my gmail password';
$connection = imap_open($connect_to, $user, $password)
or die("Can't connect to '$connect_to': " . imap_last_error());
imap_close($connection);
?>
Error I am getting:
PHP Warning:imap_open(): Couldn't open stream {imap.gmail.com:993/imap/ssl}INBOX in /home/re-work/test_imap.php on line 30
Array
(
[type] => 2
[message] => imap_open(): Couldn't open stream {imap.gmail.com:993/imap/ssl}INBOX
[file] => /home/re-work/test_imap.php
[line] => 30
)
PHP Warning: imap_num_msg() expects parameter 1 to be resource, boolean given in /home/re-work/test_imap.php on line 39
PHP Warning: imap_search() expects parameter 1 to be resource, boolean given in /home/re-work/test_imap.php on line 42
0</br>PHP Notice: Unknown: Retrying PLAIN authentication after [ALERT] Please log in via your web browser: https://support.google.com/mail/acco (errflg=1) in Unknown on line 0
PHP Notice: Unknown: Retrying PLAIN authentication after [ALERT] Please log in via your web browser: https://support.google.com/mail/acco (errflg=1) in Unknown on line 0
PHP Notice: Unknown: Can not authenticate to IMAP server: [ALERT] Please log in via your web browser: https://support.google.com/mail/acco (errflg=2) in Unknown on line 0
Please help where and what I am missing?
Related
I'm using PHP 7.4.15 and Gmail IMAP to fetch emails from server.
Same credentials work on QA env but failing on my local machine, I'm using the following code:
$username = 'testing+some_email_queue#example.com';
$password = '<some password>';
$imap = imap_open('{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX', $username, $password);
var_dump($imap);
I'm running my code example using the following command: php -f imap.php and output is:
PHP Warning: imap_open(): Couldn't open stream {imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX in C:\Projects\<path>\imap.php on line 9
Warning: imap_open(): Couldn't open stream {imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX in C:\Projects\<path>\imap.php on line 9
bool(false)
PHP Notice: Unknown: [AUTHENTICATIONFAILED] Invalid credentials (Failure) (errflg=1) in Unknown on line 0
Notice: Unknown: [AUTHENTICATIONFAILED] Invalid credentials (Failure) (errflg=1) in Unknown on line 0
PHP Notice: Unknown: [AUTHENTICATIONFAILED] Invalid credentials (Failure) (errflg=1) in Unknown on line 0
Notice: Unknown: [AUTHENTICATIONFAILED] Invalid credentials (Failure) (errflg=1) in Unknown on line 0
PHP Notice: Unknown: [AUTHENTICATIONFAILED] Invalid credentials (Failure) (errflg=1) in Unknown on line 0
Notice: Unknown: [AUTHENTICATIONFAILED] Invalid credentials (Failure) (errflg=1) in Unknown on line 0
PHP Notice: Unknown: Too many login failures (errflg=2) in Unknown on line 0
Notice: Unknown: Too many login failures (errflg=2) in Unknown on line 0
In my php.ini file imap extension is enabled.
Any idea what might be the reason?
Searched all through Server Fault and Stack Overflow, but cannot find any useful information regarding this issue I have. There are plenty of questions regarding getting connected to Exchange, but that's not where my issue is.
I am running php-imap (latest via composer) and have setup a PHP script to connect to Office 365/Exchange to check for bounced messages. The script executes and works correctly, however throws some confusing connection errors.
The basic script:
$imap_server = 'outlook.office365.com';
$imap_folder = 'INBOX';
$imap_user = '((myemailaddress))';
$imap_pass = '((mypasswrod))';
$mailbox = new PhpImap\Mailbox ('{' . $imap_server . '}' . $imap_folder, $imap_user, $imap_pass);
try {
$mailsIds = $mailbox->searchMailbox('ALL', true);
print_r ($mailsIds);
} catch(PhpImap\Exceptions\ConnectionException $ex) {
echo "IMAP connection failed: " . $ex;
die();
}
Output:
Array
(
[0] => 47
[1] => 49
[2] => 51
[3] => 53
[4] => 55
[5] => 57
[6] => 59
)
Notice: Unknown: Connection failed to MNZ-efz.ms-acdc.office.com,143: No route to host (errflg=1) in Unknown on line 0
Notice: Unknown: Connection failed to MNZ-efz.ms-acdc.office.com,143: No route to host (errflg=1) in Unknown on line 0
Notice: Unknown: Connection failed to MNZ-efz.ms-acdc.office.com,143: No route to host (errflg=1) in Unknown on line 0
Notice: Unknown: Connection failed to MNZ-efz.ms-acdc.office.com,143: No route to host (errflg=1) in Unknown on line 0
EDIT:
Further - it appears all emails in the INBOX are being deleted upon execution of the script. Not sure why... but it seems it would have something to do with whatever is happening here in the background that is causing those errors.
this is my code
$hostname = '{outlook.office365.com:993/imap/ssl}INBOX';
$username = 'email#example.com';
$password = 'password';
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to `Gmail: ' . imap_last_error());`
I have copied this code form another website to test but i am getting this error!!
Warning: imap_open(): Couldn't open stream {imap.gmail.com:993/imap/ssl}INBOX in E:\xampp\htdocs\mail\index.php on line 42
Cannot connect to Gmail: Too many login failures
Notice: Unknown: [AUTHENTICATIONFAILED] Invalid credentials (Failure) (errflg=1) in Unknown on line 0
Notice: Unknown: [AUTHENTICATIONFAILED] Invalid credentials (Failure) (errflg=1) in Unknown on line 0
Notice: Unknown: [AUTHENTICATIONFAILED] Invalid credentials (Failure) (errflg=1) in Unknown on line 0
Notice: Unknown: Too many login failures (errflg=2) in Unknown on line 0
I am trying to access my gmail inbox using imap. I have applied almost all the possible solutions available here and also in google. But i am facing the same issue.
Below is my code :
$hostname = "{imap.gmail.com:993/imap/ssl/novalidate-cert}";
$mailbox = imap_open($hostname, 'my gmail account', 'my gmail password');
if ($mailbox)
{
echo 'if';
}
else
{
echo 'else';
}
exit;
When i run this code in to my local system it will give me some message like this :
Warning: imap_open(): Couldn't open stream {imap.gmail.com:993/imap/ssl/novalidate-cert} in D:\xampp\htdocs\php-imap-mailboxes\test-mail.php on line 4
else
Notice: Unknown: [ALERT] Please log in via your web browser: https://support.google.com/mail/accounts/answer/78754 (Failure) (errflg=1) in Unknown on line 0
Notice: Unknown: [ALERT] Please log in via your web browser: https://support.google.com/mail/accounts/answer/78754 (Failure) (errflg=1) in Unknown on line 0
Notice: Unknown: [ALERT] Please log in via your web browser: https://support.google.com/mail/accounts/answer/78754 (Failure) (errflg=1) in Unknown on line 0
Notice: Unknown: Too many login failures (errflg=2) in Unknown on line 0
I am running this script in to my local system. Please help me in to this as i have already spent lot's of time in this issue.
Thanks,
Ali
Make sure you have OpenSSL installed.
Here is a related discussion on google groups.
https://groups.google.com/forum/#!topic/comp.lang.php/JB5hm8cKi_Q
How might php can connect to serial Comm?
I try use a class php_serial.class.php but that does not work, when I run the web, error occurs
Warning: Specified serial port is not valid in D:\POS\AppServ\www\Eri\ulikan\phptoserial\gagal\php_serial.class.php on line 111
Warning: The device must be set before to be open in D:\POS\AppServ\www\Eri\ulikan\phptoserial\gagal\php_serial.class.php on line 137
Warning: Device must be opened in D:\POS\AppServ\www\Eri\ulikan\phptoserial\gagal\php_serial.class.php on line 541
Warning: Device must be opened to read it in D:\POS\AppServ\www\Eri\ulikan\phptoserial\gagal\php_serial.class.php on line 474
Warning: Unable to set the baud rate : the device is either not set or opened in D:\POS\AppServ\www\Eri\ulikan\phptoserial\gagal\php_serial.class.php on line 204