Sponsored Content
Top Forums UNIX for Advanced & Expert Users sendmails works, but opens 43 file handles per email -> problem Post 302480911 by ZX81 on Thursday 16th of December 2010 06:12:34 AM
Old 12-16-2010
sendmails works, but opens 43 file handles per email -> problem

I'm using Sendmail 8.13.8 on a CentOS 5.5 vServer (Virtuozzo).

I'm using a loop in PHP to send a lot of HTML-mails via sendmail. Each mail is a mail with individual statistics for our users, so its not mass mailing, bcc is not an option.

It all works fine, but when I take a closer look there is a problem heading our way with a high number of mails:

For each mail sendmail opens up 43 files. Sometimes these open files get closed again very fast, sometimes not.

Here is an example using the PHP-script below, it sends 20 mails in a loop:


[root]# php test-mail.php
START: number of open files: 2113
END: number of open files: 2973


This is the worst case. The number of open files (lsof | wc -l) used to send the 20 mails is 860 => 43 open files per mail.

Sometimes the files are closed very fast, so I get results like this, too:


[root]# php test-mail.php
START: number of open files: 2113
END: number of open files: 2242


This shows 129 (3 * 43) open files, so the open files for 17 send mails are already closed, for 3 mails the 129 files are still open.

In the worst case and with lots of mails our server crashes, the numfile limit of 8192 in user_beancounters is reached (our ISP won't give us more than 8192).

Sendmail DeliveryMode is background.

Could it be that sendmail tries to send lots ob mails asyncronously and uses 43 open files for each? I'm only depending on sendmail to deliver the mails, normaly I wouldn't dare to touch the sendmail config (like 'if you don't know what you're doing, don't!').

Any ideas?

BTW: It is not a problem of PHP. I verified this by sending mails via SMTP localhost to sendmail (opened 43 files per mail) and sending mails via SMTP to an ISP-relay (did not open any files per mail).

Thank you very much for reading this,
best,
Andreas


This is the code for test-mail.php:

Code:
<?php
$output = shell_exec('lsof | wc -l');
echo "START: number of open files: $output";

// HTML message
$msg = '<html><head><title>Test mail</title></head><body><p>Mailbody</p></body></html>';

// Set 'Content-type'-header
$header  = 'MIME-Version: 1.0' . "\r\n";
$header .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

for($i=0; $i<20; $i++) {
	// send mail, this opens up 43 files for each
	mail('you@yourdomain.com', 'Testmail '.$i, $msg, $header, '-f bounce@yourdomain.com');
}

$output = shell_exec('lsof | wc -l');
echo "END: number of open files: $output";
?>

 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

File Handles

Hi, perhaps you can answer my question.....;) How can I check, how many file handles are used and how can i increase the value for maximum file handles??? (3 Replies)
Discussion started by: sjaeger
3 Replies

2. Shell Programming and Scripting

SSH in batch mode and File-Handles in a loop

Hi all I try to execute SSH commands on several hosts in a while-loop. There seems to be a problem with file-handle, first cycle works correct but no other one will follow due to the while condition is false even that there are many more host entries (lines) in all_hosts.dat. ... (3 Replies)
Discussion started by: DaveCutler
3 Replies

3. Shell Programming and Scripting

perl help with pipes and file handles (simple issue)

Hello, I have a program which opens a pipe for communication using file handle and forks 5 child processes. @waitlist = (1,2,3,4,5); foreach $item (@waitlist) { pipe *{$item},RETHAND; unless ($pid = fork()) { # Child process print RETHAND... (1 Reply)
Discussion started by: the_learner
1 Replies

4. Shell Programming and Scripting

Monitor open file handles used by a process

We have a process that is running out of file handles. Is there some command line way to determine this that we can include into a cron script? Please let me know JAK (3 Replies)
Discussion started by: jakSun8
3 Replies

5. UNIX for Dummies Questions & Answers

Selectionbox, script which opens more than one file at once?

hello everybody I´m very new at shell and programming :eek: and i have the following question/problem: I need a script for framemaker (based on shell) which opens a new document from a template (.fm). Then imports a .doc file and then save it as a .mif. Actually my script works with one... (3 Replies)
Discussion started by: tio86
3 Replies

6. Shell Programming and Scripting

Position to last line when vi opens a file.

Any Idea without entering any keystroke I can go to end of line in vi when I opening the file. When I am opening Vi I want to goto last line. when I give vi + filename it does not work. Any clue why it does not work. Thanks. (3 Replies)
Discussion started by: ekb
3 Replies

7. OS X (Apple)

Programatically change which opens a file type

Hi there, If we have 2 apps on our customers machines that can both open files of a certain file extension, is there any way via shell commands to set which application should be the default? Essentially, I'm hoping to replicate Get Info > Open With > Change All, but using a script. Thanks... (0 Replies)
Discussion started by: davewg
0 Replies

8. UNIX for Advanced & Expert Users

How UNIX/AIX handles a file deep down, say it's being read while another one tries to rename it?

Hi Thinkers, On AIX 5.3, we have a monitor program that reads the log file and searching for a certain string pattern that we define(say "transactionException"), if it sees it then it will raise an alert by sending an email. Because the log file XXX.log is rolling into XXX.log.0, XXX.log.1,... (2 Replies)
Discussion started by: TheGunMan
2 Replies

9. UNIX for Dummies Questions & Answers

Script to leak file handles

This is a strange one. We have an issue where our system is leaking SCTP file handles. There are people working on this and in the mean time we have a monitoring script that alarms when we need to perform actions to manually clear them. For testing purposes I want to write a script that... (0 Replies)
Discussion started by: RECrerar
0 Replies
SENDMAILCONFIG(8)					      System Manager's Manual						 SENDMAILCONFIG(8)

NAME
sendmailconfig - configure sendmail for Debian systems SYNOPSIS
sendmailconfig [--no-reload] DESCRIPTION
sendmailconfig is used to simplify the configuration of sendmail(8) for use on Debian systems. In the simplest case, you may run this program to (re)configure sendmail for your Debian system at any time. It will modify the file /etc/mail/sendmail.mc in order to create a working sendmail configuration which will be written to the file /etc/mail/sendmail.cf. For advanced configurations, you can modify the sendmail.mc file before generating sendmail.cf. Future invokations of sendmailconfig will preserve these changes provided they are made at the end of the file. Normally sendmailconfig will ask if you want to reload sendmail after making changes to its configuration. The --no-reload option will avoid this question. FILES
/etc/mail/sendmail.mc sendmail m4 input to generate sendmail.cf /etc/mail/sendmail.cf actual sendmail configuration file /etc/mail/sendmail.cw names for which we will accept mail in the standard configuration /etc/mail/sendmail.ct names of trusted users in the standard configuration SEE ALSO
sendmail(8) AUTHOR
Robert Leslie <rob@mars.org> 21-Jan-1997 SENDMAILCONFIG(8)
All times are GMT -4. The time now is 07:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy