Create Canned Responses using PHP Auto-Replies

Today, We want to share with you Create Canned Responses using PHP Auto-Replies.In this post we will show you How To Create Canned Responses in PHP, hear for How to Send Canned Responses as Auto-Replies in PHP we will give you demo and example for implement.In this post, we will learn about How to Create Email Templates in PHP: With Canned Responses with an example.

Create Canned Responses using PHP Auto-Replies

There are the Following The simple About Create Canned Responses using PHP Auto-Replies Full Information With Example and source code.

As I will cover this Post with live Working example to develop PHP Canned Responses as Auto-Replies in Gmail, so the PHP Canned Responses for this example is following below.

How to setup canned responses in PHP

require('members.inc.php');
include_once(INCLUDE_DIR.'class.canned.php');

/* check Your permission */
if(!$thismembers || !$thismembers->canManageCannedResponses()) {
    header('Location: kb.php');
    exit;
}

Free Download Example – Pakainfo.com

Also Read :  Connect Multiple Databases in CodeIgniter

PHP script to send Auto Replies(Canned Responses)

TODO: Support multiplefilesuploads(Attachments)!

$canned=null;
if($_REQUEST['id'] && !($canned=Canned::lookup($_REQUEST['id'])))
    $resError['error_msg']='UnValid or invalid canned response ID.';

if($_POST && $thismembers->canManageCannedResponses()) {
    switch(strtolower($_POST['do'])) {
        case 'update':
            if(!$canned) {
                $resError['error_msg']='UnValid or invalid canned response.';
            } elseif($canned->update($_POST, $resError)) {
                $msg='Canned response updated successfully';

                $peoples = $_POST['files']?$_POST['files']:array();
                $multiplefilesuploads = $canned->multiplefilesuploads->getSeparates(); //current list of multiplefilesuploads.
                foreach($multiplefilesuploads as $k=>$file) {
                    if($file['id'] && !in_array($file['id'], $peoples)) {
                        $canned->multiplefilesuploads->delete($file['id']);
                    }
                }

                if($_FILES['multiplefilesuploads'] && ($files=AttachmentFile::format($_FILES['multiplefilesuploads'])))
                    $canned->multiplefilesuploads->upload($files);


                if (isset($_POST['draft_id'])
                        && ($draft = Draft::lookup($_POST['draft_id']))) {
                    $canned->multiplefilesuploads->deleteInlines();
                    $canned->multiplefilesuploads->upload(
                        $draft->getAttachmentIds($_POST['response']),
                        true);
                }

                $canned->reload();
                Draft::deleteForNamespace('canned.'.$canned->getId());
            } elseif(!$resError['error_msg']) {
                $resError['error_msg']='Error updating canned response. Try again!';
            }
            break;
        case 'create':
            if(($id=Canned::create($_POST, $resError))) {
                $msg='Canned response added successfully';
                $_REQUEST['a']=null;

                if($_FILES['multiplefilesuploads'] && ($c=Canned::lookup($id)) && ($files=AttachmentFile::format($_FILES['multiplefilesuploads'])))
                    $c->multiplefilesuploads->upload($files);


                if (isset($_POST['draft_id'])
                        && ($draft = Draft::lookup($_POST['draft_id'])))
                    $c->multiplefilesuploads->upload(
                        $draft->getAttachmentIds($_POST['response']), true);

  
                Draft::deleteForNamespace('canned', $thismembers->getId());
            } elseif(!$resError['error_msg']) {
                $resError['error_msg']='Unable to add canned response. Correct error_msgor(s) below and try again.';
            }
            break;
        case 'mass_process':
            if(!$_POST['message_ids'] || !is_array($_POST['message_ids']) || !count($_POST['message_ids'])) {
                $resError['error_msg']='You must select at least one canned response';
            } else {
                $count=count($_POST['message_ids']);
                switch(strtolower($_POST['a'])) {
                    case 'enable':
                        $sql='UPDATE '.CANNED_TABLE.' SET status=1 '
                            .' WHERE canned_id IN ('.implode(',', db_input($_POST['message_ids'])).')';
                        if(db_query($sql) && ($num=db_affected_rows())) {
                            if($num==$count)
                                $msg = 'choose your canned responses enabled';
                            else
                                $warn = "$num of $count choose your canned responses enabled";
                        } else {
                            $resError['error_msg'] = 'Unable to enable choose your canned responses.';
                        }
                        break;
                    case 'disable':
                        $sql='UPDATE '.CANNED_TABLE.' SET status=0 '
                            .' WHERE canned_id IN ('.implode(',', db_input($_POST['message_ids'])).')';
                        if(db_query($sql) && ($num=db_affected_rows())) {
                            if($num==$count)
                                $msg = 'choose your canned responses disabled';
                            else
                                $warn = "$num of $count choose your canned responses disabled";
                        } else {
                            $resError['error_msg'] = 'Unable to disable choose your canned responses';
                        }
                        break;
                    case 'delete':

                        $i=0;
                        foreach($_POST['message_ids'] as $k=>$v) {
                            if(($c=Canned::lookup($v)) && $c->delete())
                                $i++;
                        }

                        if($i==$count)
                            $msg = 'choose your canned responses deleted successfully';
                        elseif($i>0)
                            $warn="$i of $count choose your canned responses deleted";
                        elseif(!$resError['error_msg'])
                            $resError['error_msg'] = 'Unable to delete choose your canned responses';
                        break;
                    default:
                        $resError['error_msg']='Sorry, Your methods UnValid command';
                }
            }
            break;
        default:
            $resError['error_msg']='UnValid action';
            break;
    }
}

///How To Create Canned Responses using PHP
$page='cannedresponses.inc.php';
if($canned || ($_REQUEST['a'] && !strcasecmp($_REQUEST['a'],'add')))
    $page='cannedresponse.inc.php';

$nav->setTabActive('kbase');
require(STAFFINC_DIR.'header.inc.php');
require(STAFFINC_DIR.$page);
include(STAFFINC_DIR.'footer.inc.php');
?>

Angular 6 CRUD Operations Application Tutorials

Read :

Also Read :  Laravel Global variable Sharing Data with all views

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Create Canned Responses using PHP Auto-Replies.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Recommended For You.

Laravel 5.7 Delete Confirm Bootstrap jQuery Model
Today, We want to share with you Laravel 5.7 Delete Confirm Bootstrap jQuery Model.In this post we will show you

Add a Comment

Your email address will not be published. Required fields are marked *