dev2761:
Where is the file input field called "filename".
Also, you shouldn't really hijack someone elses thread.
Mark
adding attachment to...
Moderator: General Moderators
its here in the upload form:
and please excuse me for "hijacking" but I have posted this elsewhere and it is some sort of follow up to the proposed problem.
Once again I'm sorry, please excuse me.
Code: Select all
<input type='file' name='filename' accept='image/jpg'>Once again I'm sorry, please excuse me.
Code: Select all
function admin_send_msg() {
global $list_name, $list_file, $owner_email, $fileatt;
set_time_limit(0);
$subject = stripslashes($GLOBALSїsubject]);
$message = stripslashes($GLOBALSїmessage]);
$subject = str_replace("%%", """, $subject);
$message = str_replace("%%", """, $message);
$headers = "From: "$list_name" <$owner_email>
\r\nReply-To: $owner_email
\r\nX-Sender: $owner_email
\r\nX-UnsubscribeURL: http://$GLOBALSї'HTTP_HOST']$GLOBALSї'SCRIPT_NAME']
\r\nX-Mailer: Newsletter v$GLOBALSї'version']
\r\nX-AntiSpam: Newsletter did not send you this email, review below for sender info.
\r\nX-AntiSpam: Sent by $GLOBALSї'REMOTE_ADDR']
\r\n$attach
r\n"\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary="{$mime_boundary}"";
if ($GLOBALSї'SERVER_ADMIN']) $headers .= "X-AntiSpam: Server Administrator $GLOBALSїSERVER_ADMIN]\r\n";
if ($GLOBALSї'use_sig'] == "on") $message .= $GLOBALSї'sig'];
$sucess_count = 0;
$fail_count = 0;
$addresses = @file($list_file) or die("<center><b>The list data file could not be opened.</b><br>Check the path and permissions.</center>");
$addressesї] = $owner_email;
set_time_limit(0);
foreach ($addresses as $email) {
$email = trim($email);
if (mail($email, $subject, $message, $headers, $fileatt)) $sucess_count++;
else $fail_count++;
}
echo "<h3 align="center">Your message was sucessfully sent to $sucess_count addresses.</h3><h4 align="center">There was $fail_count unsucessfully sent.</h4>";
}i recoded most of it, but im still not getting the attachment sent. anyone heve any ideas about this?
write message
confirm message
send message
Code: Select all
$subject = $_POSTї'subject'];
$message = $_POSTї'message'];
$uploadedfile = $_FILESї'uploadedfile'];
if (!$uploadedfileї'tmp_name']) {
$uploadedfileї'tmp_name'] = "/home/virtual/site3/fst/var/www/html/_work/maillist/uploads/noatt.txt";
$uploadedfileї'name'] = "noatt.txt";
}
$fileatt = $uploadedfileї'tmp_name']; // Path to the file
$fileatt_type = "application/octet-stream"; // File Type
$fileatt_name = "$uploadedfileї'name']"; // Filename that will be used for the file as the attachment
$email_from = "$list_name"; // Who the email is from
$email_subject = "$subject"; // The Subject of the email
$email_message = "$message"; // Message that the email has in it
$headers = "From: ".$email_from;
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary="{$mime_boundary}"";
$email_message .= "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type:text/html; charset="iso-8859-1"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$email_message . "\n\n";
$data = chunk_split(base64_encode($data));
$email_message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name="{$fileatt_name}"\n" .
//"Content-Disposition: attachment;\n" .
//" filename="{$fileatt_name}"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";write message
Code: Select all
function admin_write_msg() {
global $username, $password, $owner_email, $list_name, $admin_keyword;
echo "
<form enctype="multipart/form-data" method="post">
<input type="hidden" name="username" value="$username">
<input type="hidden" name="password" value="$password">
<input type="hidden" name="action" value="$admin_keyword">
<input type="hidden" name="q" value="send_msg_confirm">
<input type="hidden" name="MAX_FILE_SIZE" value="2000000">
<table align="center" border="0">
<tr><td colspan="2" align="center" valign="top"><font size="+1"><b>Send A Message:</b><br> </td></tr>
<tr><td align="left" valign="top"><b>From: </b></td><td align="left" valign="top">"$list_name" <$owner_email></td></tr>
<tr><td align="left" valign="top"><b>Subject: </b></td><td align="left" valign="top"><input type="text" name="subject" size="35"></td></tr>
<tr><td align="left" valign="top"><b>Message: </b></td><td align="left" valign="top"><textarea rows="15" cols="65" wrap="off" name="message"></textarea></td></tr>
<tr><td align="left" valign="top"><b>Attachment: </b></td><td align="left" valign="top"><input name="uploadedfile" type="file"></td></tr>
<tr><td></td><td align="left" valign="top"><input type="checkbox" checked name="use_sig"><font size="-1"><i> Append Signature</i></td></tr>
<tr><td></td><td align="left" valign="top"><input type="submit" value="Send"> <input type="reset" value="Clear"></td></tr></table>
</form>";
}confirm message
Code: Select all
function admin_send_msg_confirm() {
global $username, $password, $subject, $message, $owner_email, $list_name, $list_file, $admin_keyword, $use_sig, $uploadedfile;
$subject = stripslashes($subject);
$message = stripslashes($message);
echo "
<form method="post">
<table align="center" border="0">
<tr><td colspan="2" align="center" valign="top"><font size="+1"><b>Please Confirm this is what you wish to send:</b><br> </td></tr>
<tr><td align="left" valign="top"><b>From: </b></td><td align="left" valign="top">"$list_name" <$owner_email></td></tr>
<tr><td align="left" valign="top"><b>Subject: </b></td><td align="left" valign="top">$subject</td></tr>
<tr><td align="left" valign="top"><b>Attachment: </b></td><td align="left" valign="top">$uploadedfile</td></tr>
<tr><td align="left" valign="top"><b>Message: </b></td><td align="left" valign="top"><pre>$message</pre></td></tr>";
$subject = str_replace(""", "%%", $subject);
$message = str_replace(""", "%%", $message);
echo"
<input type="hidden" name="username" value="$username">
<input type="hidden" name="password" value="$password">
<input type="hidden" name="message" value="$message">
<input type="hidden" name="subject" value="$subject">
<input type="hidden" name="uploadedfile" value="$uploadedfile">
<input type="hidden" name="use_sig" value="$use_sig">
<input type="hidden" name="action" value="$admin_keyword">
<input type="hidden" name="q" value="send_msg">
<tr><td></td><td align="left" valign="top"><input type="submit" value="Send"> <input type="reset" value="Edit" OnClick="history.go(-1); return true;"></td></tr></table>
</form>";
}send message
Code: Select all
function admin_send_msg() {
global $list_name, $list_file, $owner_email;
set_time_limit(0);
$subject = stripslashes($GLOBALSїsubject]);
$message = stripslashes($GLOBALSїmessage]);
$subject = str_replace("%%", """, $subject);
$message = str_replace("%%", """, $message);
$mime_boundary = "<<<--==+Xї".md5(time())."]";
if ($GLOBALSї'SERVER_ADMIN']) $headers .= "X-AntiSpam: Server Administrator $GLOBALSїSERVER_ADMIN]\r\n";
if ($GLOBALSї'use_sig'] == "on") $message .= $GLOBALSї'sig'];
$sucess_count = 0;
$fail_count = 0;
$addresses = @file($list_file) or die("<center><b>The list data file could not be opened.</b><br>Check the path and permissions.</center>");
$addressesї] = $owner_email;
set_time_limit(0);
foreach ($addresses as $email) {
$email = trim($email);
if (mail($email, $subject, $message, $headers)) $sucess_count++;
else $fail_count++;
}
echo "<h3 align="center">Your message was sucessfully sent to $sucess_count addresses.</h3><h4 align="center">There was $fail_count unsucessfully sent.</h4>";
}