php - PHPMailer: Attach a file located on server -
i'm trying send (up 4) attachments using phpmailer. files on server.
this how script works:
user sees job or resume , contacts them using contact form. contact form stores data along attachments on server. review message filtering out spams/scams. if message genuine send message through.
i have information stored on server , im able send information via email attachments not sending.
here code used send mail:
if ($_get['status'] == 'approve') { $id = $_get['id']; dbconnect($dbuser, $dbpass, $db); $sql = "select * $db.mail id = $id"; $results=mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_array($results, mysql_assoc)) { $id = $row["id"]; $to = $row["to"]; $from = $row["from"]; $subject = $row["subject"]; $message = $row["message"]; $file1 = $row["file1"]; $file2 = $row["file2"]; $file3 = $row["file3"]; $file4 = $row["file4"]; $result = mysql_query("update mail set `status` = '1', `approvedtime` = now() id = " . $_get['id']) or die(mysql_error()); header("location: mail.php"); // phpmailer - start $email = new phpmailer(); $email->setlanguage('ja'); $email->from = $from; $email->fromname = 'mysite.com'; $email->subject = $subject; $email->body = $message; $email->addaddress($to); if (!empty($file1)) { $file1 = 'upload/'.$file1; $email->addattachment($file1); } if (!empty($file2)) { $file2 = 'upload/'.$file2; $email->addattachment($file2); } if (!empty($file3)) { $file3 = 'upload/'.$file3; $email->addattachment($file3); } if (!empty($file4)) { $file4 = 'upload/'.$file4; $email->addattachment($file4); } return $email->send(); // phpmailer - start } } elseif ($_get['status'] == 'reject') { dbconnect($dbuser, $dbpass, $db); $result = mysql_query("update mail set `status` = '2', `approvedtime` = now() id = " . $_get['id']) or die(mysql_error()); header("location: mail.php"); }
why attachments not sending? missing step in code or have incorrect?
thanks help!
Comments
Post a Comment