🕵️ SicherheitslückenHak5: Hackers Just Poisoned the Rust Supply Chain | Threat Wire(01.09.2026 um 14:00 Uhr)
🕵️ SicherheitslückenHak5: Hackers Found a Way Into Humanoid Robots | Threat Wire(04.09.2026 um 15:04 Uhr)
🔧 AI Nachrichten Bits und so #1021 (Passwort für Laufwerk)(31.08.2026 um 22:15 Uhr)
🔧 AI Nachrichten Bits und so #1022 (Wie Weißbier)(06.09.2026 um 20:39 Uhr)
🍏 iOS / Mac OSHue-App 6.0 ist da: das sind die Neuerungen(07.09.2026 um 17:21 Uhr)
🕵️ SicherheitslückenHak5: Hackers Just Poisoned the Rust Supply Chain | Threat Wire(01.09.2026 um 14:00 Uhr)
🕵️ SicherheitslückenHak5: Hackers Found a Way Into Humanoid Robots | Threat Wire(04.09.2026 um 15:04 Uhr)
🔧 AI Nachrichten Bits und so #1021 (Passwort für Laufwerk)(31.08.2026 um 22:15 Uhr)
🔧 AI Nachrichten Bits und so #1022 (Wie Weißbier)(06.09.2026 um 20:39 Uhr)
🍏 iOS / Mac OSHue-App 6.0 ist da: das sind die Neuerungen(07.09.2026 um 17:21 Uhr)

🔧 Programmierung 🕛 kürzlich 4 Min Lesezeit
0

Help Needed: Struggling to Set Up PHP Mailer for My Contact Form

↗ Quelle (dev.to)
🗣️ Stimme:

Hey Dev Community! 👋



I’m a digital marketing enthusiast and beginner in PHP, and I need some help with a problem on my website.



My Website

📍



The Issue

The contact form came with a prebuilt PHP file located in includes/sendmail.php. Unfortunately, the script uses the outdated mail() function, which Hostinger (my hosting provider) told me is insecure and not recommended. They advised me to use PHPMailer, which is preinstalled on their business hosting plans.



I’ve read articles about setting up PHPMailer, but honestly, it’s all a bit overwhelming for me since I’ve never worked with PHP before. The template author hasn’t responded, and I’m stuck trying to figure this out.



Details

Domain: Registered with GoDaddy

Hosting: Hostinger Business Plan

Current Mail Script: The outdated mail() function script is here:




CODE
<?php

// Read the form values
$success = false;
$successTxt = "";
$senderName = isset( $_POST['name'] ) ? preg_replace( "/[^\.\-\' a-zA-Z0-9]/", "", $_POST['name'] ) : "";
$senderEmail = isset( $_POST['email'] ) ? preg_replace( "/[^\.\-\_\@a-zA-Z0-9]/", "", $_POST['email'] ) : "";
$subject = isset( $_POST['subject'] ) ? preg_replace( "/[^\.\-\' a-zA-Z0-9]/", "", $_POST['subject'] ) : "";
$budget = isset( $_POST['budget'] ) ? preg_replace( "/^[A-Za-z0-9\\-\\.]+$/", "", $_POST['budget'] ) : "";
$message = isset( $_POST['message'] ) ? preg_replace( "/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", "", $_POST['message'] ) : "";
$txt = "Client budget: " . $budget . "\n\n" . $message . "\n\n" . "Regards,\n\n" . $senderName . " | " .$senderEmail;

// If all values exist, send the email
if ( $senderName && $senderEmail && $message ) {
$mailTo = "[email protected]"; // change it to your host mail for example ([email protected]).
$headers = "From: " . $senderEmail;
$success = mail( $mailTo, $subject, $txt, $headers );
$successTxt = "<p class='uk-alert uk-alert-success uk-margin-large-bottom success' data-uk-alert=''>Thanks for contacting us. We will contact you ASAP!</p>";
echo $successTxt;
}

?>






What I Need

I want to replace this script with a secure PHPMailer-based script. Hostinger has preinstalled PHPMailer, and I’ve been told it’s more reliable. I found an article about setting it up, but it’s too confusing for me as someone new to PHP.



This is what I have right now:




CODE
<?php
require 'vendor/autoload.php';

use PHPMailer\PHPMailer\PHPMailer;

$mail = new PHPMailer;

$mail->isSMTP();
$mail->SMTPDebug = 0;
$mail->Host = 'smtp.hostinger.com';
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = 'c;Ge?H9unUs#:T0J';
$mail->setFrom('[email protected]', 'Dusan Walla');
$mail->addReplyTo('[email protected]', 'Dusan Walla');

// Read the form values and sanitize them to prevent injection attacks
$senderName = isset($_POST['name']) ? preg_replace("/[^\.\-\' a-zA-Z0-9]/", "", $_POST['name']) : ""; // Remove any characters that are not letters, numbers, spaces, dots, hyphens, or apostrophes
$senderEmail = isset($_POST['email']) ? preg_replace("/[^\.\-\_\@a-zA-Z0-9]/", "", $_POST['email']) : ""; // Remove any characters that are not letters, numbers, dots, hyphens, underscores, or @
$subject = isset($_POST['subject']) ? preg_replace("/[^\.\-\' a-zA-Z0-9]/", "", $_POST['subject']) : ""; // Remove any characters that are not letters, numbers, spaces, dots, hyphens, or apostrophes
$budget = isset($_POST['budget']) ? preg_replace("/[^\.\-\' a-zA-Z0-9]/", "", $_POST['budget']) : ""; // Remove any characters that are not letters, numbers, spaces, dots, hyphens, or apostrophes
$message = isset($_POST['message']) ? preg_replace("/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", "", $_POST['message']) : ""; // Remove any email headers to prevent header injection

$mail->addAddress('[email protected]', 'Dusan Walla');
$mail->Subject = $subject;
$mail->Body = <<<EOD
Client budget: $budget

$message

Regards,

$senderName | $senderEmail
EOD;

if (!$mail->send()) {
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo "<p class='uk-alert uk-alert-success uk-margin-large-bottom success' data-uk-alert=''>Thanks for contacting us. We will contact you ASAP!</p>";
}
}
?>







Questions

How do I replace this script with PHPMailer in the simplest way possible?

Is there a step-by-step guide that breaks down what I need to do?

How do I configure Hostinger’s SMTP settings in the script?

Any help would be deeply appreciated! 🙏



Additional Resources

Here’s the article I was referring to: How to Use PHPMailer for Secure Email Sending



Thank you in advance for your guidance! 😊

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
Hackers Just Poisoned the Rust Supply Chain | Threat Wire
1 Quelle
Hackers Found a Way Into Humanoid Robots | Threat Wire
1 Quelle
Bits und so #1021 (Passwort für Laufwerk)
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Help Needed: Struggling to Set Up PHP Mailer for My Contact Form

Thematisch verwandte Begriffe: Help, Needed, Struggling, Mailer · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...