firstly, i have to admit that i am fairly new to coding, thus my question here might be actually not as dire as i made it to be.
so i want to use phpmailer for sending email to my gmail account from my html form, and i've been using brackets all these time, which works nicely so far. the problem is, after the autoload.php not working at all, as well as my email.php code, which looks like this:
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'vendor\autoload.php';
$mail = new PHPMailer(TRUE);
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
try{
$mail->isSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = TRUE;
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->Username = "mymail@gmail.com";
$mail->Password = "abcdefg";
$mail->setFrom("mymail@gmail.com");
$mail->addAddress("$email", "$name");
$mail->isHTML(true);
$mail->Subject = "my name is $name, and i want your service.";
$mail->Body = "$message"
$mail->send();
header("Location: index.php");
exit()
} catch (Exception $e){
echo $e->errorMessage();
} catch (\Exception $e){
echo $e->getmessage();
}
?>
while the autoload.php is unchanged from how it is when created automatically in composer.
when i try to run either of those on brackets, i don't even get an error message, just "HTTP error 500", which is usually only appears when it detects typo on my php code. however, as far as i've been looking, i can't find any typo on my code, or at least something that resembles it that i'm aware of.
any help would be appreciated.
update
while i haven't figured the solution yet, i did make a little progress on identifying the problem:
first, brackets will immediately cut off live preview for php codes when there's a typo somewhere, preventing the code to display any error message, or even any disply at all, even if it is already turned on inside php.ini, hence the "HTTP error 500". i've tried looking at their troubleshooting page as bracket themselves suggested, but none of those are PHP related, only troubleshooting listed on their pages is for HTML, CSS and JS related stuff.
second, i tried commenting out line by line on those 2 php code, per Nico Haase's suggestion (thanks buddy!), and i managed to find the line that caused the problem:
- for autoload.php, it's this line, which placed at the last line of code:
return ComposerAutoloaderInit13552c2f1381e274e5e1189791fc34af::getLoader();
i have no idea what typo is present in that line, so if anyone can help point it out, it'll be helpful.
-for email.php, i managed to find the typos, so i can now display error message, but the cause is this line apparently:
$mail = new PHPMailer(TRUE);
and the error message displayed is like this:
Warning: require(C:\Users\ASUS\Desktop\web ezra baru\vendor\composer/../starkbank/ecdsa/src/ellipticcurve.php): Failed to open stream: No such file or directory in C:\Users\ASUS\Desktop\web ezra baru\vendor\composer\autoload_real.php on line 55
Fatal error: Uncaught Error: Failed opening required 'C:\Users\ASUS\Desktop\web ezra baru\vendor\composer/../starkbank/ecdsa/src/ellipticcurve.php' (include_path='.;C:\php\pear') in C:\Users\ASUS\Desktop\web ezra baru\vendor\composer\autoload_real.php:55 Stack trace: #0 C:\Users\ASUS\Desktop\web ezra baru\vendor\composer\autoload_real.php(38): composerRequire13552c2f1381e274e5e1189791fc34af('79f66bc0a1900f7...', 'C:\Users\ASUS\D...') #1 C:\Users\ASUS\Desktop\web ezra baru\vendor\autoload.php(12): ComposerAutoloaderInit13552c2f1381e274e5e1189791fc34af::getLoader() #2 C:\Users\ASUS\Desktop\web ezra baru\email.php(9): require('C:\Users\ASUS\D...') #3 {main} thrown in C:\Users\ASUS\Desktop\web ezra baru\vendor\composer\autoload_real.php on line 55
i still don't understand how to fix that error specifically, so help would be appreciated.
thanks in advance!