Jump to content

How do i send a file with formmail?


JJohnsenDK

Recommended Posts

Hey

i got this script where i want to add a variable which can send files with the mails, how do i do that?

Here is the code:

[code]
if ($_POST[op] == "send") {

$file = $_POST['file'];
$subject = $_POST['subject'];
//want to send form, so check for required fields
if ($_POST[subject] =="") {
  echo "Du har ikke skrevet et emne.";
  exit;
  }

if($_POST[message] == "") {
echo "Du har ikke skrevet noget tekst.";
exit;
}

  $subject = wordwrap($subject, 77, "<br />\n");
 
  //connect to database
  $conn = mysql_connect("localhost", "user", "pass")
or die(mysql_error());
  mysql_select_db("db",$conn) or die(mysql_error());

  //get emails from subscribers list
  $sql = "select email from subscribers";
  $result = mysql_query($sql,$conn) or die(mysql_error());

  //create a From: mailheader
  $header = "From: Katrinelund\n";

  //loop through results and send mail
  while ($row = mysql_fetch_array($result)) {
  set_time_limit(0);
  $email = $row['email'];
  mail("$email", stripslashes($_POST[subject]), stripslashes($_POST[message]), $header);
  print "Nyhedsbrev sendt til: $email<br>";
  }
}[/code]
Link to comment
https://forums.phpfreaks.com/topic/28621-how-do-i-send-a-file-with-formmail/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.