Vicidial Voicemail over Gmail now working?

When getting the call to the voicemail, usually the email received at mostly email service provider but not over Gmail?

Tagged:

Answers

  • sachin
    edited September 13

    This is because, asterisk uses localhost in order to send the email not the SMTP and Gmail often rejects the email that are not send over TLS. To do that we can send the voicemail using SMTP.

    There can be 2 methods which we can use.

    Method 1: Send Voicemail via External program in the hangup extension

    We will use an external program to send the email with attachment with the message. This method provides more flexibility and control on what and how we want to send.

    Step 1: Add the entry to the Dial plan.

    [trunkinbound]
    ; Dialplan Entries
    
    
    ; FastAGI for VICIDIAL/astGUIclient call logging
    exten => h,1,AGI(agi://127.0.0.1:4577/call_log--HVcauses--PRI-----NODEBUG-----${HANGUPCAUSE}-----${DIALSTATUS}-----${DIALEDTIME}-----${ANSWEREDTIME})
    
    ; Our code goes here ;
    exten => h,n,GotoIf($[${LEN(VM_MESSAGEFILE)}>5]?trunkinbound,h,endhere)
    exten => h,n,System(php /var/lib/asterisk/agi-bin/voicemail.php ${CALLERID(dnid)} ${VM_MESSAGEFILE})
    ; exten => h,n,NoOp(${SYSTEMSTATUS})
    exten => h,n(endhere),NoOp(END)
    

    Step 2: Write the program which will get 2 parameter values. 1st: User Caller-ID and 2nd: Voicemail file path.

    You can use PHPMailer to send the mail via Email. Here's a little snippet

    <?php
    // ob_start();
        require_once('/var/www/html/admin/dbconnect_mysqli.php');
        require_once('/var/www/html/admin/functions.php');
    
        $vm_file    = $argv[0];
        $vm_user    = $argv[1];
        $vm_path    = $argv[2];
    
        if($vm_file && $vm_user && $vm_path && file_exists($vm_path.".txt")){
            $vm_data = parse_ini_file($vm_path.".txt", true);
    
            if(isset($vm_data['message']) && !empty($vm_data['message'])){
                $origmailbox = $vm_data['message']['origmailbox'];
                $stmt="SELECT * from vicidial_voicemail where voicemail_id='$origmailbox';";
                $rslt=mysql_to_mysqli($stmt, $link);
                $row=mysqli_fetch_assoc($rslt);
                if(isset($row['email']) && !empty($row['email'])){
                    $body = "
    <!DOCTYPE html>
    <html>
    <head>
        <style>
            /* You can style it accordingly*/
        </style>
    </head>
    <body>
        <p>
            Dear ".$row['fullname'].",
        </p>
        <p>
            You have just received a voicemail on your mailbox \"".$vm_data['message']['origmailbox']."\" from ".$vm_data['message']['callerid']." on ".$vm_data['message']['origdate'].", so you might want to check when you get a chance. Thanks!
        </p>
        <table id=\"customers\">
          <tr>
            <th colspan=\"2\">Details:</th>
          </tr>
          <tr>
            <td>Tollfree</td>
            <td>".$vm_user."</td>
          </tr>
        </table>
    </body>
    </html>";
                    // You can use PHPMailer to send the email to send the $body
                }else{
                    // $fastagi->verbose("\e[1;31m ##### Voicemail to email failed #####\e[0m");
                }
            }
        }
    
    // $contents = ob_get_contents();
    // ob_end_clean();
    // $myfile = fopen("/var/lib/asterisk/agi-bin/vm_log/log.txt", "a") or die("Unable to open file!");
    ?>
    


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!