Jump to content

Any help would be appreciated please!


kingpinuk

Recommended Posts

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 116
PHP Warning:  imap_num_msg() expects parameter 1 to be resource, boolean given in /var/www/vhosts/cvdatabase.management/httpdocs/send_email.php on line 151
PHP 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

Link to comment
Share on other sites

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 by CroNiX
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.