Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
HELP! PHP MAILER add attachment!
Old 06-07-2008, 05:42 PM HELP! PHP MAILER add attachment!
Junior Talker

Posts: 1
Trades: 0
hello, i have been trying to get a code where the person that want to send an image or images do not exceed 4mb. please help!
please help, i have been looking for more than 12 hours
javier08 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-07-2008, 06:16 PM Re: HELP! PHP MAILER add attachment!
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
*Puts "PHP MAILER add attachment" into google*
#1 http://phpmailer.codeworxtech.com/examples.html - At the bottom of this page is the code you need.

PHP Code:
require("mail.inc.php");

// Instantiate your new class
$mail = new MyMailer;

// Now you only need to add the necessary stuff
$mail->AddAddress("josh@site.com""Josh Adams");
$mail->Subject "Here is the subject";
$mail->Body    "This is the message body";
########## This is were you put the link to the attachment #############
$mail->AddAttachment("c:/temp/11-10-00.zip""new_name.zip");  // optional name
########################################################

if(!$mail->Send())
{
   echo 
"There was an error sending the message";
   exit;
}

echo 
"Message was sent successfully"
And, if you want to check the file is not over 2mb use the filesize( http://uk.php.net/manual/en/function.filesize.php ) function like this:
PHP Code:
<?php
$filename 
'somefile.txt';
#     2 megabytes = 2 097 152 bytes
if(filesize($filename) <  2 097 152){ // It's smaller than 2mb
echo $filename ': ' filesize($filename) . ' bytes';
} else {
echo 
"file to big.";
}
?>
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE

Last edited by rogem002; 06-07-2008 at 06:21 PM..
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Reply     « Reply to HELP! PHP MAILER add attachment!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.20358 seconds with 12 queries