SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    May 2014
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question What am i doing wrong? PHP & IMAP [HELP]

    Hello there i am hoping for some help. so when i call this function to mark a email i have opened as read, this is the following code:
    function mark_email_as_read() {

    $user_id = $_SESSION[$this->session_prefix.'_user_id'];

    $msgnum = $this->common_model->search_get($this->url,'msgnumber');
    $acc = $this->common_model->search_get($this->url,'acc');
    $folder = $this->common_model->search_get($this->url,'accfolder');

    $ssl = false;

    $ssl=($ssl==false)?"/novalidate-cert":"";

    $host = $this->email_accounts[$this->the_helpdesk_view][$this->the_helpdesk_company]['server'];
    $port = $this->email_accounts[$this->the_helpdesk_view][$this->the_helpdesk_company]['port'];
    $folder = $this->email_accounts[$this->the_helpdesk_view][$this->the_helpdesk_company]['folder'];
    $user = $this->email_accounts[$this->the_helpdesk_view][$this->the_helpdesk_company]['user'];
    $pass = $this->email_accounts[$this->the_helpdesk_view][$this->the_helpdesk_company]['pass'];

    $this->imap = imap_open("{"."$host:$port/imap$ssl"."}$folder", $user, $pass);

    $uid = imap_uid($imap_connection, $msgnum);

    imap_setflag_full($imap_connection,$uid,"\\Seen",ST_UID);

    imap_headers($this->imap);
    This is the error i am recieving:

    Notice: Undefined variable: imap_connection in /var/www/vhosts/talent.co.uk/httpdocs/intranet/model/the_helpdesk.php on line 1548 Warning: imap_uid(): supplied argument is not a valid imap resource in /var/www/vhosts/talent.co.uk/httpdocs/intranet/model/the_helpdesk.php on line 1548 Notice: Undefined variable: imap_connection in /var/www/vhosts/talent.co.uk/httpdocs/intranet/model/the_helpdesk.php on line 1550 Warning: imap_setflag_full(): supplied argument is not a valid imap resource in /var/www/vhosts/talent.co.uk/httpdocs/intranet/model/the_helpdesk.php on line 1550
    i dont understand where im going wrong and whats happeneing.

    could you please help.

  2. #2
    Community Advisor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,441
    Mentioned
    45 Post(s)
    Tagged
    13 Thread(s)
    Hi Jamie, welcome to the forums!

    I think the cause of the errors is this section of code:
    PHP Code:
    $this->imap imap_open("{"."$host:$port/imap$ssl"."}$folder"$user$pass);

    $uid imap_uid($imap_connection$msgnum);

    imap_setflag_full($imap_connection,$uid,"\\Seen",ST_UID); 
    You're opening a connection with imap_open and assigning it to $this->imap, but in the next line you're using the variable $imap_connection. Probably what you want to be doing is this:
    PHP Code:
    $this->imap imap_open("{"."$host:$port/imap$ssl"."}$folder"$user$pass);

    $uid imap_uid($this->imap$msgnum);

    imap_setflag_full($this->imap$uid"\\Seen"ST_UID); 
    "There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies and the other way is to make it so complicated that there are no obvious deficiencies."


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •