Senior & Expert PHP Developers Discussion Forum by Nyros Technologies

HIRE PHP Expert Developers Programmers Coders From India
PHP .Net Ruby on Rails Developers Community, Nyros Technologies, Kakinada
 
Log in  or IF not a member please REGISTER
Username:
Password:   


Keyword
Log in | Profile 

How to add doc file as attachment to sending mail from php?

 
Post new topic   Reply to topic    Senior & Expert PHP Developers Discussion Forum by Nyros Technologies Index -> Webmail
View previous topic :: View next topic  
Author Message
AnilKumar



Joined: 09 May 2008
Posts: 173

PostPosted: Mon Sep 08, 2008 8:58 am    Post subject: How to add doc file as attachment to sending mail from php? Reply with quote

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 Razz


Last edited by AnilKumar on Mon Sep 08, 2008 9:10 am; edited 1 time in total
Back to top
View user's profile Send private message
samir



Joined: 12 Nov 2007
Posts: 231

PostPosted: Mon Sep 08, 2008 9:07 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Senior & Expert PHP Developers Discussion Forum by Nyros Technologies Index -> Webmail
Page 1 of 1

 latest topics 
 Topics   Replies   Author   Views   Last Post 
No new posts how to add 20 minutes in past date
2 Mike 21 Wed Mar 10, 2010 1:29 pm
Mike View latest post
No new posts display the date in given range
3 Mike 45 Wed Mar 10, 2010 5:21 am
AnilKumar View latest post
No new posts Get the random values from mysql
0 AnilKumar 6 Wed Mar 10, 2010 4:43 am
AnilKumar View latest post
No new posts About Expression Engine
1 Thirupathi 69 Mon Mar 08, 2010 2:31 pm
nih View latest post
No new posts content type=text/html and and image/jpeg in same php file?
3 Mike 76 Fri Mar 05, 2010 5:16 am
AnilKumar View latest post
No new posts how to create xls file using mysql and php?
4 AnilKumar 2786 Fri Mar 05, 2010 5:08 am
AnilKumar View latest post
No new posts Who Expert can do this
0 ismaelhaider 45 Tue Mar 02, 2010 10:53 am
ismaelhaider View latest post
No new posts online Remote printing through php
1 new2it 51 Mon Mar 01, 2010 2:10 pm
new2it View latest post
No new posts Php script to display the days between two dates?
0 Thirupathi 40 Fri Feb 26, 2010 10:49 am
Thirupathi View latest post
No new posts About PEAR in php?
0 Thirupathi 31 Thu Feb 25, 2010 7:12 am
Thirupathi View latest post





Hire an expert PHP developer / coder / programmer or development team from India now!!

Other Forums : Ruby on Rails   ::   .Net   |   Free unlimited HTML CSS Joomla Wordpress Drupal templates download

Nyros Technologies   |   Developers Blog   |   Kakinada City Portal   |   About PHP Experts   |   More