Click here to Skip to main content
15,849,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
For some reason I do not know how to solve this problem, how to connect SMTP to my titan email.

here is the code:



$mail = new PHPMailer();

//$mail->SMTPDebug = 3;                               // Enable verbose debug output
$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'smtp.titan.emaill';  // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                                             // Enable SMTP authentication
$mail->Username = '';                 // SMTP username
$mail->Password = '';             // SMTP password
$mail->SMTPSecure = true;                            // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465;                                    // TCP port to connect to

$message = "";
$status = "false";

    if( $_POST['form_name'] != '' AND $_POST['form_email'] != '' AND $_POST['form_subject'] != '' ) {

        $name = $_POST['form_name'];
        $email = $_POST['form_email'];
        $subject = $_POST['form_subject'];
        $phone = $_POST['form_phone'];
        $message = $_POST['form_message'];

        $subject = isset($subject) ? $subject : 'New Message | Contact Form';

        $botcheck = $_POST['form_botcheck'];

        $toemail = ''; // Your Email Address
        $toname = 'Stil_Trade'; // Your Name

        if( $botcheck == '' ) {

            $mail->SetFrom( $email , $name );
            $mail->AddReplyTo( $email , $name );
            $mail->AddAddress( $toemail , $toname );
            $mail->Subject = $subject;

            $name = isset($name) ? "Name: $name<br><br>" : '';
            $email = isset($email) ? "Email: $email<br><br>" : '';
            $phone = isset($phone) ? "Phone: $phone<br><br>" : '';
            $message = isset($message) ? "Message: $message<br><br>" : '';

            $referrer = $_SERVER['HTTP_REFERER'] ? '<br><br><br>This Form was submitted from: ' . $_SERVER['HTTP_REFERER'] : '';

            $body = "$name $email $phone $message $referrer";

            $mail->MsgHTML( $body );
            $sendEmail = $mail->Send();

            if( $sendEmail == true ):
                $message = 'Vaša poruka je uspješno poslata.';
                $status = "true";
                $message = 'Došlo je do  greške. Molimo Vas pokušajte ponovo.' . $mail->ErrorInfo . '';
                $status = "false";
        } else {
            $message = 'Spam Spam.!Spam';
            $status = "false";
    } else {
        $message = 'Molimo Vas da popunite sva polja i pokušate ponovo.';
        $status = "false";
} else {
    $message = 'Došlo je do  greške Molimo Vas pokušajte ponovo..';
    $status = "false";

$status_array = array( 'message' => $message, 'status' => $status);
echo json_encode($status_array);

This error pops up when I click send message:

} else {
        $message = 'Molimo Vas da popunite sva polja i pokušate ponovo.';
        $status = "false";

Do you know how to solve this problem, im using hostinger hosting and plans. I'm connected to Titan Email and thats where I should receive messages.

What I have tried:

I tried by typing password of email there, I also tried changing to but I do not know how to solve this, may you please help me ?
Updated 29-May-23 2:55am
Richard MacCutchan 28-May-23 9:33am    
What is the error message in English?
the wolf 2023 28-May-23 9:45am    
To fill all the fields in the form
Richard MacCutchan 28-May-23 9:55am    
OK, so that is what you need to do. As far as I can see this is your code, and you are producing the error message. So it should be obvious why the problem occurs.
the wolf 2023 28-May-23 9:56am    
But all the fields are filled and im still getting this error :/
Richard MacCutchan 28-May-23 10:00am    
Sorry, but we cannot see the actual form data that is being returned. You will need to use the debugger to trace why it is going to the error block.

1 solution

Your error referes back to your first line ofr validation -
if( $_POST['form_name'] != '' AND $_POST['form_email'] != '' AND $_POST['form_subject'] != '' )

which tells you that one of your required fields is empty. The way to solve this is to go back one page to your html form and carry out all the validations in their respective text elements. If any element is empty, do not POST the form, let the user complete the information as required. When all validations were passed, then POST your form and your code should run fine.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900