update 1.0.7
This commit is contained in:
@@ -19,8 +19,6 @@ use Crypt;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
//use PhpImap\Mailbox as ImapMailbox;
|
||||
|
||||
/**
|
||||
* ======================================
|
||||
* EmailsController.
|
||||
@@ -120,9 +118,14 @@ class EmailsController extends Controller
|
||||
|
||||
return $return_data;
|
||||
}
|
||||
if ($request->validate == 'on') {
|
||||
$validate = '/validate-cert';
|
||||
} else {
|
||||
$validate = '/novalidate-cert';
|
||||
}
|
||||
if ($request->fetching_status == 'on') {
|
||||
$imap_check = $this->getImapStream($request);
|
||||
if ($imap_check == 0) {
|
||||
$imap_check = $this->getImapStream($request, $validate);
|
||||
if ($imap_check[0] == 0) {
|
||||
return 'Incoming email connection failed';
|
||||
}
|
||||
$need_to_check_imap = 1;
|
||||
@@ -143,17 +146,17 @@ class EmailsController extends Controller
|
||||
|
||||
if ($need_to_check_imap == 1 && $need_to_check_smtp == 1) {
|
||||
if ($imap_check != 0 && $smtp_check != 0) {
|
||||
$this->store($request);
|
||||
$this->store($request, $imap_check[1]);
|
||||
$return = 1;
|
||||
}
|
||||
} elseif ($need_to_check_imap == 1 && $need_to_check_smtp == 0) {
|
||||
if ($imap_check != 0 && $smtp_check == 0) {
|
||||
$this->store($request);
|
||||
$this->store($request, $imap_check[1]);
|
||||
$return = 1;
|
||||
}
|
||||
} elseif ($need_to_check_imap == 0 && $need_to_check_smtp == 1) {
|
||||
if ($imap_check == 0 && $smtp_check != 0) {
|
||||
$this->store($request);
|
||||
$this->store($request, null);
|
||||
$return = 1;
|
||||
}
|
||||
} elseif ($need_to_check_imap == 0 && $need_to_check_smtp == 0) {
|
||||
@@ -174,14 +177,14 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function store($request)
|
||||
public function store($request, $imap_check)
|
||||
{
|
||||
// dd($request);
|
||||
$email = new Emails();
|
||||
try {
|
||||
// getConnection($request->input('email_name'), $request->input('email_address'), $request->input('email_address'))
|
||||
// saving all the fields to the database
|
||||
if ($email->fill($request->except('password', 'department', 'priority', 'help_topic', 'fetching_status', 'sending_status', 'auto_response'))->save() == true) {
|
||||
if ($email->fill($request->except('password', 'department', 'priority', 'help_topic', 'fetching_status', 'fetching_encryption', 'sending_status', 'auto_response'))->save() == true) {
|
||||
if ($request->fetching_status == 'on') {
|
||||
$email->fetching_status = 1;
|
||||
} else {
|
||||
@@ -197,7 +200,12 @@ class EmailsController extends Controller
|
||||
} else {
|
||||
$email->auto_response = 0;
|
||||
}
|
||||
// fetching department value
|
||||
if ($imap_check !== null) {
|
||||
$email->fetching_encryption = $imap_check;
|
||||
} else {
|
||||
$email->fetching_encryption = $request->fetching_encryption;
|
||||
}
|
||||
// fetching department value
|
||||
$email->department = $this->departmentValue($request->input('department'));
|
||||
// fetching priority value
|
||||
$email->priority = $this->priorityValue($request->input('priority'));
|
||||
@@ -289,8 +297,13 @@ class EmailsController extends Controller
|
||||
return $return_data;
|
||||
}
|
||||
// return $request;
|
||||
if ($request->validate == 'on') {
|
||||
$validate = '/validate-cert';
|
||||
} else {
|
||||
$validate = '/novalidate-cert';
|
||||
}
|
||||
if ($request->fetching_status == 'on') {
|
||||
$imap_check = $this->getImapStream($request);
|
||||
$imap_check = $this->getImapStream($request, $validate);
|
||||
if ($imap_check == 0) {
|
||||
return 'Incoming email connection failed';
|
||||
}
|
||||
@@ -425,7 +438,7 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return type int
|
||||
*/
|
||||
public function getImapStream($request)
|
||||
public function getImapStream($request, $validate)
|
||||
{
|
||||
$fetching_status = $request->input('fetching_status');
|
||||
$username = $request->input('email_address');
|
||||
@@ -433,13 +446,20 @@ class EmailsController extends Controller
|
||||
$protocol_id = $request->input('mailbox_protocol');
|
||||
$fetching_protocol = '/'.$request->input('fetching_protocol');
|
||||
$fetching_encryption = '/'.$request->input('fetching_encryption');
|
||||
if ($fetching_encryption == 'none') {
|
||||
$fetching_encryption = 'novalidate-cert';
|
||||
if ($fetching_encryption == '/none') {
|
||||
$fetching_encryption2 = '/novalidate-cert';
|
||||
$mailbox_protocol = $fetching_encryption2;
|
||||
$host = $request->input('fetching_host');
|
||||
$port = $request->input('fetching_port');
|
||||
$mailbox = '{'.$host.':'.$port.$mailbox_protocol.'}INBOX';
|
||||
} else {
|
||||
$mailbox_protocol = $fetching_protocol.$fetching_encryption;
|
||||
$host = $request->input('fetching_host');
|
||||
$port = $request->input('fetching_port');
|
||||
$mailbox = '{'.$host.':'.$port.$mailbox_protocol.$validate.'}INBOX';
|
||||
$mailbox_protocol = $fetching_encryption.$validate;
|
||||
}
|
||||
$mailbox_protocol = $fetching_protocol.$fetching_encryption;
|
||||
$host = $request->input('fetching_host');
|
||||
$port = $request->input('fetching_port');
|
||||
$mailbox = '{'.$host.':'.$port.$mailbox_protocol.'}INBOX';
|
||||
|
||||
try {
|
||||
$imap_stream = imap_open($mailbox, $username, $password);
|
||||
} catch (\Exception $ex) {
|
||||
@@ -447,9 +467,9 @@ class EmailsController extends Controller
|
||||
}
|
||||
$imap_stream = imap_open($mailbox, $username, $password);
|
||||
if ($imap_stream) {
|
||||
$return = 1;
|
||||
$return = [0 => 1, 1 => $mailbox_protocol];
|
||||
} else {
|
||||
$return = 0;
|
||||
$return = [0 => 0];
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
Reference in New Issue
Block a user