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: 174

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: 232

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 Problem to create a folder in my server
1 samir 8 Mon Mar 15, 2010 7:32 am
rajkumar View latest post
No new posts cake php
1 Mike 15 Mon Mar 15, 2010 6:07 am
rajkumar View latest post
No new posts query in many table..how to read it
0 mun 11 Sun Mar 14, 2010 8:03 am
mun View latest post
No new posts search data in many table
0 mun 9 Sun Mar 14, 2010 7:57 am
mun View latest post
No new posts HipHop for PHP is now opensource
0 venkatadapa 13 Sat Mar 13, 2010 7:08 am
venkatadapa View latest post
No new posts Get the status from twitter using PHP script
0 Thirupathi 10 Fri Mar 12, 2010 8:57 am
Thirupathi View latest post
No new posts music portal script
0 realcoder 11 Thu Mar 11, 2010 8:42 pm
realcoder View latest post
No new posts DataExporter.php anybody make or tell
0 realcoder 14 Thu Mar 11, 2010 8:33 pm
realcoder View latest post
No new posts Email sending through PHP program
1 kumar1116 60 Thu Mar 11, 2010 10:29 am
AnilKumar View latest post
No new posts Php script to display the days between two dates?
1 Thirupathi 67 Thu Mar 11, 2010 9:09 am
Mike 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