Note that there are some explanatory texts on larger screens.

plurals
  1. POA few questions regarding IMAP via PHP
    primarykey
    data
    text
    <p>I'm trying to figure out how to customize this piece of PHP code in such a way, so that I can set two specific conditions, based on the PHP error notices that I am receiving.</p> <pre><code>&lt;?php /* connect to yahoo */ $hostname = '{imap.mail.yahoo.com:993/imap/ssl}INBOX'; $username = 'user@yahoo.com'; $password = 'password'; $alerts = imap_alerts() /* try to connect */ $inbox = imap_open($hostname,$username,$password) or die('Cannot connect to yahoo: ' . $alerts); if ( $inbox === false ) { exit ("Can't connect: " . imap_last_error() ."\n"); } else { echo"Logined:"; //do stuff } ?&gt; </code></pre> <p>What I wanna accomplish is:</p> <ol> <li>Connect to the IMAP server.</li> <li>Check if the user/password combo is correct, and if so, log me in ( I got that covered ).</li> <li>If it isn't, I will just be greeted with an IMAP error stating "Too many login failures".</li> <li>If it is, but I am trying to log in from a location that Yahoo doesn't recognize, that is, I have never logged in from there before, I will get the same error.</li> <li>Depending on whether the user/pass combo is incorrect, or the location isn't recognized, redirect the user to either "page1" or "page2".</li> </ol> <p>The imap_last_error returns the same error for both cases. The error alerts ( imap_alerts ), however, are different for both cases, and this is where I can differentiate between them.</p> <p>How can I set it up so that when it attempts to log in, and it receives an error notice, containing a certain text string, it would just read that text string ( not displaying the errors at all ), and redirect to either "1" or "2"?</p> <p>The redirect itself should not be a problem. The differentiation is what's tripping me up here. I would like the IMAP notice received to be dumped into a text file ( or, ideally, read directly ), and, depending on whether it contains "String A" or "String B", the next script action will be a redirect to either Page 1 or Page 2.</p> <p>IMAP wrong user/pass combo notice: </p> <p>Notice: Unknown: [AUTHORIZATIONFAILED] Incorrect username or password.</p> <p>IMAP unknown location notice: </p> <p>Notice: Unknown: [AUTHORIZATIONFAILED] Please verify your account at <a href="https://login.yahoo.com" rel="nofollow">https://login.yahoo.com</a>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload