I explain in 3 simple steps:
-
I insert exactlythis code that you just gave me, and echo $link to make sure that the code for retrieving the url is not the problem (and remove the refresh function):
[php]
<?PHP
$imap = imap_open("{imap.one.com}","—", “—”);
if( $imap ) {
$MC = imap_check($imap);
// Fetch an overview for all messages in INBOX
$result = imap_fetch_overview($imap,“4200:{$MC->Nmsgs}”,0);
foreach ($result as $overview) {
$nr = “{$overview->msgno}”;
$seen = “{$overview->seen}”;
if($seen == “0”) {
$text = imap_fetchbody($imap,$nr,1);
$pos = strpos($text, “http”);$http = substr($text, $pos);$end = strpos($http, ‘=’);if ($end>0); else $end = strpos($http, " ");
if ($end>0) {
$link = substr($http, 0, $end);}
else
{
$link = substr($http, 0);
}
$ok=‘1’;
echo "URL retrieved: ".$link;
}
}
}
?>
>
There was an email, so $ok = '1'... Two pages will be opened...
<script>
function open2pages() {
window.open('<?PHP echo $link; ?>');
window.open('alarm.php');
};
</script>
[/php]
-
I mark an email as unread, refresh the page and nothing happens, except the correct $link is echoed.
-
I replace [php]window.open(’<?PHP echo $link; ?>’);[/php] with [php]window.open(‘alarm.php’);[/php] (to localize the error), mark an email as unread, refresh the page and two tabs with sounds are appearing - as well as the correct $link echoed.