0

I created a contact formular with html and php. I already installed xampp and everything. In the php.ini file I set up the smtp server. When I try the contact formular than this error in line 15 show up:

Warning: mail(): SMTP server response: 530 5.7.0 Authentication required in C:\xampp\htdocs\mdn\mail.php on line 15
Error!

This is my mail.php file:

<?php
if(isset($_POST['name']))
    $name = $_POST['name'];
if(isset($_POST['email']))
    $email = $_POST['email'];
if(isset($_POST['message']))
    $message = $_POST['message'];
if(isset($_POST['subject']))
    $subject = $_POST['subject'];

$content = "From: $name \n Email: $email \n Message: $message";
$recipient = "behar@zenuni.ch";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $content, $mailheader) or die ("Error!");
echo "Email sent!";
?>

Can somebody help me?

aynber
  • 22,380
  • 8
  • 50
  • 63
zenubeh
  • 67
  • 1
  • 1
  • 9
  • You need the password of the sender – Stefan Jul 26 '18 at 14:00
  • 1
    Have a look at this: https://stackoverflow.com/questions/712392/send-email-using-the-gmail-smtp-server-from-a-php-page will help you set up SMTP for PHP mail(). – Adam Jul 26 '18 at 14:01
  • this ink doesn't help. It shows for GMAIL. My mail is hosted from another company. But I don't know how to set it up. Can you help me? – zenubeh Jul 26 '18 at 14:45
  • Check the help section of the company that hosts your mail. If they allow sending they will have a section on how to configure things. – Dave Jul 26 '18 at 14:50

1 Answers1

0

php mail function does not provide any way to authenticate.

you will need to use a 3rd party library to send mail.

I use PHPMailer, but there are many others.

PHPMailer can be found here https://github.com/PHPMailer/PHPMailer with install instructions, usage and simple examples

Clint
  • 973
  • 7
  • 18
  • @zenubeh I have updated my post with links to PHPMailer download/install/instructions/example. – Clint Jul 31 '18 at 11:08