| View previous topic :: View next topic |
| Author |
Message |
AnilKumar

Joined: 09 May 2008 Posts: 173
|
Posted: Mon Sep 08, 2008 8:58 am Post subject: How to add doc file as attachment to sending mail from php? |
|
|
hi to all,
can any one help me in this concept, in my project i want to add a doc file as attachment with the file, through the php mailer class.
thanks in advance
Anil Kumar 
Last edited by AnilKumar on Mon Sep 08, 2008 9:10 am; edited 1 time in total |
|
| Back to top |
|
 |
samir
Joined: 12 Nov 2007 Posts: 231
|
Posted: Mon Sep 08, 2008 9:07 am Post subject: |
|
|
hi, using php mailer class,
we can attach the doc file as attachment when sending the mail.
$docFile=$_FILES['docFile']['name'];
$docFileSize=$_FILES['docFile']['size'];
$ext=substr($docFile,-4);
$flag=0;
if (($docFileSize<=50000) && ($ext=='.doc'))
{
move_uploaded_file($_FILES["docFile"]["tmp_name"], "upload_docs/" .$docFile);
$flag=1;
}
else
{
$flag=0;
}
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsMail();
$mail->Timeout = 360;
$body = "testing";
// Customer Email and Name
$mail->From = "admin@localhost.com";
$mail->FromName = "Test";
// code for attach the file
$mail->AddAttachment("upload_docs/" .$docFile);
// Reply Email
$mail->AddReplyTo( "test@yahoo.com", "Testing");
// Email Receipent Address
$mail->AddAddress($toemail, '');
$mail->AddAddress('test@yahoo.com', 'test');
$mail->IsHTML(true);
$mail->Subject = "Test Subject";
$mail->Body = $body;
if($flag==1)
{
if($body != "") {
$mail->Send();
}
} |
|
| Back to top |
|
 |
|