kingpinuk Posted January 26, 2015 Share Posted January 26, 2015 Hi we had some software develops that needs to bulk upload from a mailbox. When we are setting up a Cron job within the Plesk control panel on the dedicated server our developer is getting the follow error and not sure of a solution? - Can anyone advise please - Thank you! Getting the following message when I run the cron:PHP Warning: imap_open(): Couldn't open stream {localhost} in /var/www/vhosts/cvdatabase.management/httpdocs/send_email.php on line 116PHP Warning: imap_num_msg() expects parameter 1 to be resource, boolean given in /var/www/vhosts/cvdatabase.management/httpdocs/send_email.php on line 151PHP Notice: Unknown: Certificate failure for localhost: self signed certificate: /C=US/ST=Virginia/L=Herndon/O=Parallels/OU=Parallels Panel/CN=Parallels Panel/emailAddress=info@parallels.com (errflg=2) in Unknown on line 0 Quote Link to comment Share on other sites More sharing options...
ginerjm Posted January 26, 2015 Share Posted January 26, 2015 So now you should be showing us the code that is pointed to by these error messages. Maybe some lines prior to them as well so we have some context Quote Link to comment Share on other sites More sharing options...
CroNiX Posted January 26, 2015 Share Posted January 26, 2015 (edited) You need to open like: $mailbox = "{mail.thedomain:993/novalidate-cert/ssl}INBOX"; //use the actual mail domain/ssl port, ignore self signed cert, use SSL, open "INBOX" $user = 'user@thedomain.com'; //email user $password = 'password'; //email users password $mbox = imap_open($mailbox, $user, $password); //connect Edited January 26, 2015 by CroNiX Quote Link to comment Share on other sites More sharing options...
CroNiX Posted January 26, 2015 Share Posted January 26, 2015 Also, if you want, you can process these in real time instead of a cron job by creating a .forward file in the root of the mailbox and pipe the email to a script to process it. Whenever a new mail hits the mailbox, it will automatically be forwarded to the script. Personally I just use it to alert the script that a new mail hit the box and then use imap functions to retrieve like you are instead of reading the file from STDIN, since it's easier to handle attachments, etc via imap functions. Google "php pipe email to script" for more info. I just use \user-domain.com |/home/user/public_html/process_mail.php The first line tells it to deliver to the mailbox normally instead of ONLY forwarding the email (user-domain.com = user@domain.com). This leaves the email intact in the box in case something happens with our processing...then we still have the original. The 2nd line tells it to "pipe" the email to the /home/user/public_html/process_mail.php script, which has all of the imap code to retrieve the email, parse it and send it to our CRM for further processing. Quote Link to comment Share on other sites More sharing options...
CroNiX Posted January 26, 2015 Share Posted January 26, 2015 Should have been (left the .com out) $mailbox = "{mail.thedomain.com:993/novalidate-cert/ssl}INBOX"; //use the actual mail domain/ssl port, ignore self signed cert, use SSL, open "INBOX" Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.