PHP mailto () and attachement

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
new2phpcode
Forum Newbie
Posts: 21
Joined: Tue Oct 09, 2007 10:40 pm

PHP mailto () and attachement

Post by new2phpcode »

Hi, i have this code to send emails using mail function

Code: Select all

 
<?PHP
 
$hostname = "hostname";
$email1 = $custemail;
$email2 = "email@email.com";
 
$subject = "subject";
$datafooterhtml ="footer";
$datafootertxt ="data";
# -=-=-=- MIME BOUNDARY
$mime_boundary = "----project name----".md5(time());
# -=-=-=- MAIL HEADERS
$to = "$email1".","."$email2";
$headers = "headers";
# -=-=-=- TEXT EMAIL PART
$message .= "Content-Type: text/plain; charset=UTF-8\n";
$message .= "Content-Transfer-Encoding: 8bit\n\n";
$message .= "Message \n";
$message .= "\n\n";
# -=-=-=- FINAL BOUNDARY
$message .= "--$mime_boundary--\n\n";
# -=-=-=- SEND MAIL
ini_set("smtp", "mail.server.com");
ini_set ("sendmail_from","email@email.com");
$mail_sent = @mail( $to, $subject, $message, $headers );
echo $mail_sent ? "Mail sent" : "Mail failed";
?>
 


and upload file code

Code: Select all

 
<form enctype="multipart/form-data" action="uploader.php?account=<?PHP print $accountname; ?>" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
<span class="texttable">Choose a file to upload:</span> 
<input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
 
and the uploader.php

Code: Select all

 
<?PHP
$account = $_GET["accountname"];
$target_path = "uploads/";
$target_path = $target_path . $account . basename( $_FILES['uploadedfile']['name']); 
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "<script language='JavaScript' >
    alert('File has been uploaded');    
    location = 'data.php';
    </script>";
 
} else{
echo "   <script language='JavaScript' >
    alert('There was an error uploading the file...')
    location = 'data2.php'
    </script>";
} 
?>
 
 
i am having a hard time combining those two, something like a webmail function like attaching files then send it out to recepient... is there such a work around on this? Thanks so much! :D
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Re: PHP mailto () and attachement

Post by yacahuma »

use swift mailer
new2phpcode
Forum Newbie
Posts: 21
Joined: Tue Oct 09, 2007 10:40 pm

Re: PHP mailto () and attachement

Post by new2phpcode »

im not familiar with that but i will give it a try.. thanks!
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Re: PHP mailto () and attachement

Post by yacahuma »

is easy to use and have plenty of examples and their is a forum for it here
Post Reply