0

The issue is i'm trying to get the last email from my email using php, and it works fine locally. But then I uploaded the script to the client's server, and I don't get a response. When I check the logs, I get this:

[12-Feb-2020 08:43:21 location] PHP Warning:  imap_open(): Couldn't open stream {<mail>:143/imap}INBOX in /path/triggerCall.php on line 2
[12-Feb-2020 08:43:21 location] PHP Warning:  imap_headers() expects parameter 1 to be resource, boolean given in /path/triggerCall.php on line 7
[12-Feb-2020 08:43:21 location] PHP Warning:  imap_num_msg() expects parameter 1 to be resource, boolean given in /path/triggerCall.php on line 14
[12-Feb-2020 08:43:21 location] PHP Warning:  imap_header() expects parameter 1 to be resource, boolean given in /path/triggerCall.php on line 16
[12-Feb-2020 08:43:21 location] PHP Warning:  imap_fetchbody() expects parameter 1 to be resource, boolean given in /path/triggerCall.php on line 20
[12-Feb-2020 08:43:21 location] PHP Warning:  imap_close() expects parameter 1 to be resource, boolean given in /path/triggerCall.php on line 40

This is the code:

$inbox = imap_open('{<mail>:143/imap}', '<username>', '<password>');

$headers = imap_headers($inbox);

$last = imap_num_msg($inbox);

$header = imap_header($inbox, $last); 

$body = imap_fetchbody($inbox, $last,1);

I have tried:

{<mail>:993/imap/novalidate-cert}INBOX
{<mail>:995/pop3/tls}INBOX
{<mail>:995/pop3/ssl}INBOX
{<mail>:993/imap/ssl}INBOX
{<mail>:110/pop3}INBOX
{<mail>:993/imap/tls/novalidate-cert}INBOX
{<mail>:143}INBOX

But none of those approaches work. Any ideas?

F_Bass
  • 343
  • 4
  • 17
  • Truly, yet are the ports fire walled off? This is normal. Sign in with ssh and take a stab at telnetting to the server. – Arpit Jain Feb 12 '20 at 13:57
  • @ArpitJain I talked to the client's host support, and they opened the ports, but I still can't access ANY mail service, be it hotmail, gmail, or others. In my local machine I can access all of them with the same script – F_Bass Feb 14 '20 at 11:09

2 Answers2

-1

Try this

$inbox = imap_open('{mail.gmail.com/ssl/novalidate-cert}INBOX', 'email', 'password');

Sk Mourya
  • 1
  • 2
-1
$mailbox = {outlook.office365.com:993/imap/ssl}.INBOX;

$this->mbox = imap_open($mailbox,USERNAME, PASSWORD, OP_READONLY) or die("can't connect: " . imap_last_error());
  • 4
    This could be the solution that solves the problem, but please add some information on how and what all help in solving the problem, so that future readers take the most out of your answer. – Not A Bot Feb 24 '21 at 12:33