Hey thanks alot for that.
do you have a working script that i could see? with the email process.
what im doing is in the backend i have a script that when the user submits email it sends them an attachment.
thanks!
heres the scripts im using
mailer.php
Code:
<?php
require("mailer.php");
$to = $_REQUEST['email'];
$from = 'test@gmail.com';
$subject = 'Here is the subject';
$boundary = 'Message-Boundary-' . date('YmdHis');
$headers = 'From: ' . $from . "\n";
$headers .= 'Reply-To: ' . $from . "\n";
$headers .= 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: Multipart/Mixed; boundary=' . $boundary . "\n\n";
$message = '--' . $boundary . "\n";
$message .= 'Content-Transfer-Encoding: 64BIT' . "\n";
$message .= 'Content-Type: text/html; charset=US-ASCII' . "\n\n";
$message .= 'Here is your tone and pic';
$attach = true;
if($attach){
$arrfile = array('tt88616.mp3');
foreach($arrfile as $f){
$file = $f;
$attach = fopen($file, 'rb');
$data = fread($attach, filesize($file));
fclose($attach);
$data = chunk_split(base64_encode($data));
$ext = strtolower(substr(strrchr($file, '.'), 1));
switch($ext){
case 'pdf': $type = 'application/pdf'; break;
case 'exe': $type = 'application/octet-stream'; break;
case 'zip': $type = 'application/zip'; break;
case 'doc': $type = 'application/msword'; break;
case 'xls': $type = 'application/vnd.ms-excel'; break;
case 'ppt': $type = 'application/vnd.ms-powerpoint'; break;
case 'gif': $type = 'image/gif'; break;
case 'mp3': $type = 'audio/mpeg'; break;
case 'mpeg': $type ='audio/mpeg'; break;
case 'png': $type = 'image/png'; break;
case 'jpe':
case 'jpeg':
case 'jpg': $type = 'image/jpg'; break;
default: $type = 'application/force-download';
}
$message .= "\n\n" . '--' . $boundary . "\n";
$message .= 'Content-Transfer-Encoding: base64' . "\n";
$message .= 'Content-Type: ' . $type . '; name="' . $file . '";' . "\n";
$message .= 'Content-Disposition: inline; filename="' . $file . '"' . "\n\n" . $data;
}
}
mail($to, $subject, $message, $headers);
echo 'E-mail sent!';
?>
the form.php
Code:
<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$email = $_REQUEST['email'] ;
}
else
//if "email" is not filled out, display the form
{
echo "<form method='post' action='mailform.php'>
Email: <input name='email' type='text' /><br />
<input type='submit' />
</form>";
}
?>
Bookmarks