-1

i have configured postfix and i currently hosted my site in ubuntu, nginx and i have installed sendmail as well as i am completly new to this i would highly appreciate any detailed information about wheather i have to install any other services and change any configurations.thank you in advance

<?php

    if(isset($_POST['submit'])) {
        $name = $_POST['username'];
        $email = $_POST['email'];
        $number = $_POST['phone'];
        $profession = $_POST['profession'];

        $to = 'saiviharj@gmail.com';
        $subject = 'user registration';
        $phone = "phone number:".$number;
        $message = "client details:"."\n"."Name:".$name."\n"."email:".$email."\n"."phone number:".$number."\n"."profession:".$profession;
        $headers = "From:".$email;

    if(mail($to, $subject, $message, $headers)) {
        header("Location: ../../thankyouNew.html");
    } else {
        header("Location: ../../somethingWrong.html");
    }
}

?>
Brandon Minnick
  • 13,342
  • 15
  • 65
  • 123
vihar
  • 19
  • 5
  • 1
    Possible duplicate of [PHP mail function doesn't complete sending of e-mail](https://stackoverflow.com/questions/24644436/php-mail-function-doesnt-complete-sending-of-e-mail) – Qirel Sep 04 '17 at 21:24
  • I recommend you figure out why your PHPMailer didn't work instead. It's better to use that library than the built-in `mail()` function, imo. If you use the code you have right now, it's vulnerable to header-injections. – Qirel Sep 04 '17 at 21:25

1 Answers1

0

Even if you can accomplish sending an email using the mail() function, I will not recommend it to you. You will have some other problems, like spam....

so instead I would choose a SMTP Library like PHPMailer.

Here is their documentation: https://github.com/PHPMailer/PHPMailer

mmucito
  • 134
  • 5