Код: Выделить всё
Warning: require_once(/XAMPP/xamppfiles/lib/php/PHPMailer-master/src/PHPMailer.php):
Failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/development/registration_form_clock_register_short-SESSION.php on line 288
Fatal error: Uncaught Error: Failed opening required
'/XAMPP/xamppfiles/lib/php/PHPMailer-master/src/PHPMailer.php'
(include_path='.:/Applications/XAMPP/xamppfiles/lib/php') in /Applications/XAMPP/xamppfiles/htdocs/development/registration_form_clock_register_short- SESSION.php:288
Stack trace: #0 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/development/registration_form_clock_register_short-SESSION.php on line 288
Код: Выделить всё
require_once "/PHPMailer-master/src/PHPMailer.php";
Чтобы исправить фатальную ошибку, я вставил следующий include_path include_path=".:/Applications/XAMPP/xamppfiles/lib/php в свой файл php.ini:
Код: Выделить всё
;;;;;;;;;;;;;;;;;;;;;;;;;
; Paths and Directories ;
;;;;;;;;;;;;;;;;;;;;;;;;;
; UNIX: "/path1:/path2"
;include_path = ".:/php/includes"
include_path=".:/Applications/XAMPP/xamppfiles/lib/php"
Я поместил папку PHPMailer-master (и все файлы и папки, которые идут с ним) в папке: /Applications/XAMMP/xamppfiles/lib/php.
Мое кодирование PHP выглядит следующим образом:< /p>
Код: Выделить всё
$emess = "Hello world";
require_once "/PHPMailer-master/src/PHPMailer.php";
require_once "/PHPMailer-master/src/SMTP.php";
require_once "/PHPMailer-master/src/Exception.php";
require 'vendor/autoload.php';
$mail = new PHPMailer\PHPMailer\PHPMailer();
try {
//Server settings
$mail->SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output
$mail->isSMTP(); //Send using SMTP
$mail->Host = 'localhost'; //Set the SMTP server to send through
$mail->Port = 465; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
//Recipients
$mail->setFrom('clockregister@clockregister.org', 'The Clock Register');
$mail->addAddress($good_data[email]); //Name is optional
//Content
$mail->isHTML(true); //Set email format to HTML
$mail->Subject = 'One more step: confirm your registration at The Clock Register.';
$mail->Body = $emess;
$mail->AltBody = $emess;
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... r-in-macos
Мобильная версия