-3

I know how to send email without attachments. Please tell me how to send emails with single or multiple attachments. php code

<?php
if(isset($_POST['send'])){
$from=$_SESSION['email'];
to=$_POST['to'];
date1=strtotime(date("Y-m-d h:i:sa"));
subject=$_POST['subject'];
message=$_POST['message'];
$success=mail($to, "$subject", $message, "From:" . $from);
if($success) { //Email response
$mailsendquery="INSERT INTO mails (to_mail,from_mail,subject,body,date) VALUES('$to','$from','$subject','$message',$date1)";
$mailsendres=mysqli_query($db,$mailsendquery);
?>
<div class="alert alert-success alert-dismissible">
    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
     <h4><i class="icon fa fa-check"></i> Successfully sent!</h4>
</div>
<?php } else { ?>
<div class="alert alert-danger alert-dismissible">
    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
     <h4><i class="icon fa fa-ban"></i> Invalid Mail Address!</h4>
</div>
<?php } } ?>

1 Answers1

2

For your sake, I would recommend using PHPMailer (industry standard). Using mail() isn't a one-two-go! PHPMailer has easy attachment integration, and is quickly set up (as in a few lines of code).

https://github.com/PHPMailer/PHPMailer

Ron S
  • 31
  • 4