Added UTF-8 support to rsvp-submit.php #2
This commit is contained in:
@@ -3,7 +3,7 @@ require __DIR__ . '/vendor/autoload.php';
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
|
||||
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
|
||||
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/../'); // <-- root .env
|
||||
$dotenv->load();
|
||||
|
||||
$name = $_POST['name'] ?? 'No Name';
|
||||
@@ -13,8 +13,10 @@ $allergies = $_POST['allergies'] ?? 'None';
|
||||
$mail = new PHPMailer(true);
|
||||
|
||||
try {
|
||||
$mail->CharSet = 'UTF-8'; // <-- Make sure UTF-8 is used
|
||||
$mail->CharSet = 'UTF-8';
|
||||
$mail->isSMTP();
|
||||
$mail->SMTPDebug = 2; // debug mode
|
||||
$mail->Debugoutput = 'html';
|
||||
$mail->Host = $_ENV['SMTP_HOST'];
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->Username = $_ENV['SMTP_USER'];
|
||||
@@ -26,16 +28,10 @@ try {
|
||||
$mail->addAddress($_ENV['TO_EMAIL']);
|
||||
$mail->Subject = "New Wedding RSVP from $name";
|
||||
|
||||
if (!empty($_POST['email'])) {
|
||||
$mail->addReplyTo($_POST['email'], $name);
|
||||
}
|
||||
|
||||
$body = "Name: $name\nDrinks: $drinks\nAllergies: $allergies\n";
|
||||
$mail->Body = $body;
|
||||
$mail->Body = "Name: $name\nDrinks: $drinks\nAllergies: $allergies\n";
|
||||
|
||||
$mail->send();
|
||||
echo 'RSVP submitted successfully.';
|
||||
} catch (Exception $e) {
|
||||
echo "RSVP could not be sent. Mailer Error: {$mail->ErrorInfo}";
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user