Reputation: 817
Summary
I try to read the information of the first letter in my mailbox. Suppose that "mail.example.com" is my mail server site, "userid" is my e-mail address and "userpwd" is my password. Below is the PHP code.
<?php
$num=1; //To read the first letter
$MAILSERVER="{mail.example.com:143/notls}INBOX";
$link=imap_open($MAILSERVER,"userid","userpwd");
$header=imap_header($link,$num);
echo "From: $header[fromaddress]<br>";
echo "To: $header[toaddress]<br>";
echo "Date: $header[Date]<br>";
echo "Subject: $header[Subject]<br><br>";
echo imap_body($link,$num);
imap_close($link);
?>
Questions
I have two questions:
$link
has no return value when we do not add "/notls" on line 4?Upvotes: 1
Views: 292
Reputation: 1342
try this. you are using invalid array index
$MAILSERVER="{mail.example.com:143/notls}INBOX";
$link=imap_open($MAILSERVER,"userid","userpwd");
$header=imap_header($link,$num);
echo "From:". $header['fromaddress']."<br>";
echo "To:". $header['toaddress']."<br>";
echo "Date:".$header['Date']."<br>";
echo "Subject:". $header['Subject']."<br><br>";
echo imap_body($link,$num);
imap_close($link);
?>
Upvotes: 2