如果我尝试使用PHP API从Mikrotik路由器检索数据
require_once 'PEAR2_Net_RouterOS-1.0.0b5.phar';
$util = new RouterOS\Util(
$client = new RouterOS\Client($this->ip_router, $this->user_router, $this->pass_router)
);
$util->setMenu('/ip hotspot user');
$query=RouterOS\Query::where('name', 'admin')
->not()
->andwhere($conprop, $conval);
//echo $query;
$data = "";
$tempdata = "";
//echo $proplist."<br/>";
$proplist = explode(',',$proplist);
//echo $proplist[0]."<br/>";
foreach ($util->getAll(array(),$query) as $item) {
$tempdata = "";
//echo $item->getProperty(name)."<br/>";
foreach($proplist as $key => $value){
$tempdata .= "".$item->getProperty($value).",";
//echo "s=".$item->getProperty($value)."<br/>";
}
$tempdata = rtrim($tempdata,',');
//echo "<br/>";
$data .= $tempdata."#";
}
$data = rtrim($data,'#');
运行代码以使用swift邮件程序发送电子邮件:
require_once 'swift/swift_required.php';
require_once 'class_db_access.php';
session_start();
$db = new db_access;
$db->initconnection();
$config_smtp = $db->searchquery("select * from config_server where config_s_id = '2'");
$parse_config = $db->fetcharray($config_smtp);
$transport = Swift_SmtpTransport::newInstance($parse_config[1], $parse_config[4], $parse_config[5])
->setUsername($parse_config[2])
->setPassword($parse_config[3]);
$mailer = Swift_Mailer::newInstance($transport);
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
$message = Swift_Message::newInstance(''.$subject.'')
->setFrom(array(''.$from.'',''.$from.'' => ''.$alias.''))
->setTo(array($to))
->setBody($content,$cformat);
$result = $mailer->send($message);
然后我收到了这个错误:
致命错误:未捕获的异常'异常',消息为'Class 无法从Swift \ SmtpTransport.php加载Swift_SmtpTransport, 文件不存在(已注册 路径= “药业:// d:/Program/xampp1.8.3.4.0/htdocs/mikrotikcms/PEAR2_Net_RouterOS-1.0.0b5.phar/PEAR2_Net_RouterOS-1.0.0b5/src”) [PEAR2_Autoload-0.2.4]'in 药业:// d:/Program/xampp1.8.3.4.0/htdocs/mikrotikcms/PEAR2_Net_RouterOS-1.0.0b5.phar/PEAR2_Net_RouterOS-1.0.0b5/src/PEAR2/Autoload.php:181 堆栈跟踪:#0 [内部功能]: PEAR2 \ Autoload :: load('Swift_SmtpTrans ...')#1 d:\程序\ xampp1.8.3.4.0 \ htdocs中\ mikrotikcms \ class_email.php(46): spl_autoload_call('Swift_SmtpTrans ...')#2 d:\程序\ xampp1.8.3.4.0 \ htdocs中\ mikrotikcms \ action.php的(163): email-&gt; send_email('DLSU AP:Sisa K ......','noreply @ dlsuap ....','UPT PTI','10013026 @ unikad ......','\ r \ n \ t \ tDear,