require 'SendEmail.php'; //require 'class_email-small.php'; $e = new SendEmail(); $e->set_server('mail.local', 25); //$e->set_server( 'smtp.gmail.com', 587); $e->set_auth('your smtp username', 'your smtp password'); $e->set_sender('Name of sender', '*****@*****.**'); $e->set_hostname('some servers require a valid rdns name'); //$e->set_debug(true); //$e->set_crypto('ssl'); //$e->set_smtp_try(false); $subject = 'This is a text subject Ää, Öö, Üü'; $body = "This is the test body of the message\r\nIt may contain special characters: Ää, Öö, Üü\r\n"; //$e->set_type(0); /* send e-mail right away */ $e->mail('*****@*****.**', $subject, $body); echo 'last: ' . $e->srv_ret['last'] . "\n"; echo 'all: ' . $e->srv_ret['all'] . "\n"; echo 'full' . $e->srv_ret['full'] . "\n"; /* or add the message to the queue table to be processed by smtp_queue_processor.php * Please see "smtp_queue_processor.php" for the required table structure */ // $conn = mysqli_connect(); // mysqli_set_charset( $conn, 'utf8'); // $e->queue( '*****@*****.**', $subject, $body, null, $conn); // // Under Windows - also update paths in run_windows.bat // $cmd = 'T:\xampp\htdocs\class_email\run_windows.bat'; // pclose(popen('start /B '.$cmd, 'r')); // // Under Linux
$stmt_outer->bind_param("i", $CONFIG['SMTP_PROCESS_BATCH']); $stmt_outer->execute(); $stmt_outer->store_result(); $row = array(); $stmt_outer->bind_result($row['id'], $row['send_to'], $row['subject'], $row['body']); $error_count = 0; $processed_count = 0; while ($stmt_outer->fetch()) { $send_to = trim($row['send_to'], ','); if (strstr($send_to, ',')) { $asend_to = explode(',', $send_to); } else { $asend_to = array($send_to); } foreach ($asend_to as $to) { if ($e->mail($to, $row['subject'], $row['body']) === true) { if ($CONFIG['SMTP_CLEAR_SUCCESS'] === true) { $sql = 'DELETE FROM smtp_queue WHERE id = ?'; if ($stmt = mysqli_prepare($conn, $sql)) { $stmt->bind_param("i", $row['id']); $stmt->execute(); $stmt->close(); } } else { $sql = 'UPDATE smtp_queue SET send_status = 2, send_date = NOW(), smtpd_return = ? WHERE id = ?'; if ($stmt = mysqli_prepare($conn, $sql)) { $stmt->bind_param("si", $e->srv_ret['full'], $row['id']); $stmt->execute(); $stmt->close(); } }