ส่งเมล์พร้อมแนบไฟล์เสียง
เจอตัวอย่างมาจากที่นี่ php scripts นี้ใช้สำหรับส่งเมล์พร้อมแนบไฟล์เสียง โดยแปลงจาก wav ไปเป็น mp3 ด้วย lame
#!/usr/bin/php -q<?php// Include database connection detailsinclude ("ast_db_connects.php");// Invoke Asterisk PHP Libraryrequire ("phpagi.php");$agi = new AGI($cfgfile = "/etc/asterisk/phpagi.conf");// Class for sending via Sendmailrequire ("class.phpmailer.php");$vmail_ext = $agi->get_var("VMAIL_EXT");// Initialize database$db_query = "SELECT * FROM short_dials WHERE dial_code='$vmail_ext'";$db_link = mysql_connect($db_host, $db_user, $db_pass);if (!db_link) {die('Could not connect: ' . mysql_error());}@ mysql_select_db($db_name) or die("Unable to select database");//Fetch the email address and name of the person$db_result = mysql_query($db_query);$db_rows = mysql_numrows($db_result);echo "" . $db_rows . "\n\n";if ($db_rows > 0) {$email_address = mysql_result($db_result, 0, "email");$email_name = mysql_result($db_result, 0, "name");//Convert audio file from wav to mp3exec("lame -h /tmp/asterisk/voicemail.wav /tmp/asterisk/voicemail.mp3");// Send email$mail = new PHPMailer();$mail->From = "[email protected]";$mail->FromName = "Joe Blow";$mail->AddAddress("$email_address", "$email_name");$mail->AddReplyTo("[email protected]", "Joe Blow");$mail->AddAttachment("/tmp/asterisk/voicemail.mp3");$mail->Subject = "MP3 Voicemail from Mr Blow";$mail->Body = "Hello,\n\nAttached is a voicemail from me! Should play in your RealPlayer or Windows Media Player.\n\nRegards,\n\nJoe";if (!$mail->Send()) {echo "mess up\n";echo "Mailer Error: " . $mail->ErrorInfo;exit;}else {echo "Success\n";}}mysql_close($db_link);exit;
ส่งเข้า Voicemail หากโทรไม่ติด
เจอจาก http://astbill.com/node/399 อันนี้ง่ายๆ เลย ถ้าเชื่อมต่อไปแล้วมีปัญหา ปลายทางไม่รับโทรศัพท์ หรือกดวางหู (reject) จะถูกส่งเข้าไปยัง voicemail
[macro-stdexten]
; Standard extension macro:
; ${ARG1} - Extension (we could have used ${MACRO_EXTEN} here as well
exten => s,1,AGI(astlocal.agi,${ARG1})
exten => s,2,Dial(SIP/${MACRO_EXTEN},20); Ring the interface, 20 seconds maximum
exten => s,3,Goto(s-${DIALSTATUS},1); Jump based on status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)
exten => s-NOANSWER,1,Voicemail(u${VOICEMAIL}); If unavailable, send to voicemail w/ unavail announce
exten => s-NOANSWER,2,Goto(default,s,1); If they press #, return to start
exten => s-BUSY,1,Voicemail(b${VOICEMAIL}); If busy, send to voicemail w/ busy announce
exten => s-BUSY,2,Goto(default,s,1); If they press #, return to start
exten => _s-.,1,Goto(s-NOANSWER,1); Treat anything else as no answer
exten => a,1,VoicemailMain(${VOICEMAIL}); If they press *, send the user into VoicemailMain
More
uwsg.indiana.edu: asterisk-uug.pdf
vlug.org: VLUG-Telephony.pdf
wiki.ekiga.org: Asterisk and Voicemail
cavazos.com.mx: Asterisk-AGI
astricon.net: Asterisk in the Free World dialup
Asterisk tips ivr menu