473,418 Members | 2,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

PHP send mail with attachment problem. help

The code always returen the following error at fclose(fp).

Fatal error: Maximum execution time of 30 seconds exceeded in
c:\hosting\webhost4life\member\soibry\webmail\webm ail.php on line 58

The source code is:

<?php
#variable passed are $to,$from,$re,$comments,$att1

function attString($att, $att_name, $att_size, $att_type, $md5) {
if ($att_name == "")
return "";
else {
print "~~~".$att." ".$att_name." ".$att_size."~~~";

$fd = fopen($att, "r");
$fileBuf = fread($fd, $att_size);
fclose($fd);
$fileBuf = chunk_split(base64_encode($fileBuf));

return "Content-Type: $att_type;
name=\"$att_name\"\r\nContent-Transfer-Encoding:
base64\r\nContent-Disposition: attachment;
filename=\"$att_name\"\r\n\n$fileBuf\r\n--$md5--";
}
}

#get a random 32 character hexadecimal number
$num = md5(time());

#define the main headers
$hdr = "From:$from\r\n";
$hdr .= "MIME=Version: 1.0\r\n";
$hdr .= "Content-Type: multipart/mixed; ";
$hdr .= "boundary=$num\r\n";
$hdr .= "--$num\r\n"; fclose($fptr);
#define the message section
$hdr .= "Content-type: text/plain\r\n";
$hdr .= "Content-Transfer-Encoding: 8bit\r\n\n";
$hdr .= "$comments\r\n";
$hdr .= "--$num\n";
#open the file
$fp = fopen($att1, "r");
#read the file into a variable
$file = fread($fp, $att1_size);
#encode the data for safe transit and insert \r\n every 76-characters
$file = chunk_split(base64_encode($file));

#define the attachment section
$hdr .= "Content-Type: $att1_type; ";
$hdr .= "name=\"$att1_name\"\r\n";
$hdr .= "Content-Transfer-Encoding: base64\r\n";
$hdr .= "Content-Disposition: attachment; ";
$hdr .= "filename=\"$att1_name\"\r\n\n";
$hdr .= "$file\r\n";
#$hdr .= attString($att1, $att1_name, $att1_size, $att1_type, $num);
print "///".strlen($hdr);

#send the email now...
mail("****@gmail.com", $re, "", $hdr);

#close the file
fclose($fp);
?>
Jul 17 '05 #1
5 2566
nick wrote:
The code always returen the following error at fclose(fp).

Fatal error: Maximum execution time of 30 seconds exceeded in
c:\hosting\webhost4life\member\soibry\webmail\webm ail.php on line 58
Did you try setting the timeout longer?

http://www.php.net/set_time_limit
The source code is:

<?php
<snip>

Don't know that these would make any difference, but I found it odd anyway:
filename=\"$att_name\"\r\n\n$fileBuf\r\n--$md5--"; ----------------------------^
$hdr .= "Content-Transfer-Encoding: 8bit\r\n\n"; --------------------------------------------------^
$hdr .= "filename=\"$att1_name\"\r\n\n";

------------------------------------------^

Should those extra line feeds be there? Perhaps with another carriage
return as well? I don't deal with MIME encoding much, but they just
stood out when I glanced over the code.

--
Justin Koivisto - sp**@koivi.com
http://www.koivi.com
Jul 17 '05 #2
"nick" <nb**************@hotmail.com> wrote in message news:<co**********@news3.bu.edu>...
The code always returen the following error at fclose(fp).

Fatal error: Maximum execution time of 30 seconds exceeded in
c:\hosting\webhost4life\member\soibry\webmail\webm ail.php on line 58


<snip>

FWIW, use tested and trusted <http://phpmailer.sourceforge.net/>

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com
Jul 17 '05 #3
I am using a web host service (webhost4life.com) and I don't know which php
mailer program they are using. And I have no control of it too...

"R. Rajesh Jeba Anbiah" <ng**********@rediffmail.com> wrote in message
news:ab**************************@posting.google.c om...
"nick" <nb**************@hotmail.com> wrote in message
news:<co**********@news3.bu.edu>...
The code always returen the following error at fclose(fp).

Fatal error: Maximum execution time of 30 seconds exceeded in
c:\hosting\webhost4life\member\soibry\webmail\webm ail.php on line 58


<snip>

FWIW, use tested and trusted <http://phpmailer.sourceforge.net/>

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com

Jul 17 '05 #4
never mind, my nebie question. I just put the class file in the same
directory of php files and it works....

"nick" <nb**************@hotmail.com> wrote in message
news:co**********@news3.bu.edu...
I am using a web host service (webhost4life.com) and I don't know which php
mailer program they are using. And I have no control of it too...

"R. Rajesh Jeba Anbiah" <ng**********@rediffmail.com> wrote in message
news:ab**************************@posting.google.c om...
"nick" <nb**************@hotmail.com> wrote in message
news:<co**********@news3.bu.edu>...
The code always returen the following error at fclose(fp).

Fatal error: Maximum execution time of 30 seconds exceeded in
c:\hosting\webhost4life\member\soibry\webmail\webm ail.php on line 58


<snip>

FWIW, use tested and trusted <http://phpmailer.sourceforge.net/>

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com


Jul 17 '05 #5
[Top-post fixed]

"nick" <nb**************@hotmail.com> wrote in message news:<co**********@news3.bu.edu>...
"R. Rajesh Jeba Anbiah" <ng**********@rediffmail.com> wrote in message
news:ab**************************@posting.google.c om...
The code always returen the following error at fclose(fp).

Fatal error: Maximum execution time of 30 seconds exceeded in
c:\hosting\webhost4life\member\soibry\webmail\webm ail.php on line 58


<snip>

FWIW, use tested and trusted <http://phpmailer.sourceforge.net/>

I am using a web host service (webhost4life.com) and I don't know which php
mailer program they are using. And I have no control of it too...


Too sad that almost half of the c.l.php visitors are so lazy to
top-post and hesitating to click the links and read.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: marsandys | last post by:
Hello, I have this code below, which I am trying to have it send HTML formatted mail with embedded images. I can get this to send the mail, but it spits out a bunch of junk . I know this should...
2
by: Robbie De Sutter | last post by:
Hello, How do I open a new, empty e-mail message from the default e-mail client whereby the sender is given and a file is attached? Currently I use the command (vb.net): ---...
2
by: m_evergreen | last post by:
Errors: An unhandled exception of type 'System.Web.HttpException' occurred in system.web.dll Additional information: Could not access 'CDO.Message' object. innerexception is "Exception has...
2
by: Cimento Cola | last post by:
Hello all. Hope anyone can help me! I have this form, with: Please choose your file: (browse) The main purpose is the user to select a local file and then when he submits a mail should be...
3
by: =?Utf-8?B?SHVnaA==?= | last post by:
Hi There, I use follow code to send email inside VB.NET 2005. It does not work well. Error message of "Failure sending email" would occue. However, email was sent out sometimes. I am confused...
1
by: Chitu03 | last post by:
Hi I am already send a mail using Php with some attachement into it. My Problem is the attachement file is in my Database(mysql). I don't know how can i get from database and then add to my mail....
1
by: maxxxxel | last post by:
Hi Can anyone help me with some asp code , I changed the code to use CDO.message instead of the old cdont.sys to send mail from a ASP webpage which works fine. Our problem is that when we send...
1
by: sxwend | last post by:
I am trying to use the following post results (http://www.thescripts.com/forum/thread189759.html) and add another requirement. I need to send the results to just the email addresses that the query...
0
by: BuntyJ | last post by:
I have made an mail application to send mail. I am using richtextbox ver.5 for the body of mail. Most of the things is going fine, but i am facing one problem as follow: When user open an outlook...
1
by: deepaks85 | last post by:
Dear All, I want to send some data through a form with Multiple attachment in an HTML Format. I have tried it but it is not working for me. I am able to send data without attachment but with the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.