Z
Z
zhen_safronov2018-11-20 13:10:49
PHP
zhen_safronov, 2018-11-20 13:10:49

Attach file in php mail?

Good afternoon. There is a problem. It is necessary that after entering the user's email, a price list is sent to his email.
The code itself is there, but I don’t understand how to attach the file

<?php
//проверяем, существуют ли переменные в массиве POST
if(!isset($_POST['email'])){
?> <form action="send.php" method="post">
<input type="text" name="email" placeholder="Укажите e-mail" required>
<input type="submit" value="Отправить">
</form> <?php
} else {

$email = $_POST['email'];
$email = htmlspecialchars($email);
$email = urldecode($email);
$email = trim($email);


if (mail("$email", "Прайс лист с сайта автомойки", "Прайс лист для: ".$email ," \r\n")){ 
echo "Прайс успешно отправлен"; 
} else { 
echo "При отправке прайса возникли ошибки";
}
}

?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2018-11-20
@zhen_safronov

Do not reinvent the wheel, but take any class from the network to work with mail.
First available link

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question