public function __construct() { $ini = new ini_file(); $ini->setFileName('./include/config/account.ini'); $ini->load(); //$ini->printini(); echo'<br />'; $this->_login = $ini->getElementValue('user', 'login'); $this->_passwort = $ini->getElementValue('user', 'pass'); }
public function __construct() { $dbcfg = new ini_file(); $dbcfg->setFileName(CONFIG); $dbcfg->load(); $server = $dbcfg->getElementValue('db-config', 'server'); $login = $dbcfg->getElementValue('db-config', 'login'); $passwort = $dbcfg->getElementValue('db-config', 'paswort'); $default_db = $dbcfg->getElementValue('db-config', 'db_name'); //połączenie z bazą $this->mysqli = new mysqli($server, $login, $passwort, $default_db); if (mysqli_connect_errno()) { echo "Nie udało się nawiązać połączenia z bazą danych, komunikat:" . mysqli_connect_error(); exit; } $this->mysqli->set_charset("utf8"); }
function sendMail() { $checkbox_value = 0; $cfg = new ini_file(); $cfg->setFileName('./include/config/account.ini'); $cfg->load(); $user_mail = $cfg->getElementValue('user', 'mail'); $p = new ProgressBar(); $mail = new PHPMailer(); $mail->IsSMTP(); //$mail->SMTPDebug= 2; //konfiguracja serwera $mail->PluginDir = "phpmailer/"; $mail->Mailer = "smtp"; $mail->Host = $cfg->getElementValue('server-config', 'Host'); $mail->SMTPSecure = $cfg->getElementValue('server-config', 'SMTPSecure'); $mail->Port = $cfg->getElementValue('server-config', 'Port'); // $mail->SMTPKeepAlive = true; $mail->SMTPAuth = true; $mail->Username = $cfg->getElementValue('server-config', 'Login'); $mail->Password = $cfg->getElementValue('server-config', 'Passwort'); //koniec połączenia //baza danych $mydb = new Db(); $qwery = "SELECT `id`, `email` FROM mail_data Where sended=" . $checkbox_value; $request = $mydb->getMysqli()->query($qwery); if ($request === false) { die('Nie można było odebrać danych do bazy' . ' z powodu blendu:' . $mydb->getMysqli()->error); } if ($request->num_rows == 0) { echo 'Brak danych w bazie'; exit(1); } $i = 0; $size = $request->num_rows; $p->render(); while ($row = $request->fetch_assoc()) { $id = $row['id']; $address = $row['email']; $token = md5(time()); $mail->SetLanguage("pl", "phpmailer/language/"); $mail->CharSet = "UTF-8"; $mail->ContentType = "text/html"; $mail->isHTML(true); $html = new HtmlParser("./mailform/form1 - Kopia.html"); $mail->From = $user_mail; $mail->FromName = $cfg->getElementValue('user', 'FromName'); $mail->Subject = "Tytuł wiadomości"; $mail->msgHTML($html->getHtml()); $mail->AddAddress($address); try { if ($mail->Send()) { $p->setProgress($i * 100 / $size); } else { throw new Exception("E-mail nie mógł zostać wysłany, przyczyna : {$mail->ErrorInfo}"); } } catch (Exeption $e) { var_dump($e); exit; } $i++; } echo 'wysłano mail: '; $p->setProgress(100); //echo $html->getHtml(); $mail->SmtpClose(); //zamykamy połączeie }