How to use exim within PerlCGI

akira

Verified User
Joined
Sep 24, 2004
Messages
10
I have a question to you.
A sendmail function cannot be used by my PerlCGI.
I have heard that exim is used for DirectAdmin.
How do I set up, in order to use exim?

DirectAdmin + Fedora1
$sendmail = '/usr/sbin/sendmail';

open(MAIL,"| $sendmail -t") || &error("No sendmail");
print MAIL "To: $mailto\n";
print MAIL "From: $m_mailfrom\n";
print MAIL "Bcc: $bcc\n" if ($bcc);
print MAIL "Subject: $mail_sub\n";
print MAIL "MIME-Version: 1.0\n";
print MAIL "Content-type: text/plain; charset=ISO-2022-JP\n";
print MAIL "Content-Transfer-Encoding: 7bit\n";
print MAIL "X-Mailer: $ver\n\n";
print MAIL $mail_body;
close(MAIL);
 
/usr/sbin/sendmail should be a link to exim. If its not, all you need to do is make it one :)
 
Symbolic Link

Thank you.
My check carries out Symbolic Link of the /usr/sbin/sendmail to exim.
A permission is 777. The execution user is root.
 
from the command line, as a non-privileged user (admin is fine) try:

$ sendmail -t

(without the $ sign; it's just to show you that you should be a non-privileged user)

and tell us what you get.

Jeff
 
As a non-privileged user, the following messages appear.

[test@01 abc]$ sendmai -t
-bash: sendmai: command not found


As root , no messages appear.

[root@01 root]# sendmail -t
 
In the experiment using the PHP form mail software, even if it ended normally, mail transmission was not completed.
ErrorLog of Apache has the following description.

2004-11-20 23:14:34 1CVW0Y-0001DM-QB Failed to create spool file /var/spool/exim/input//1CVW0Y-0001DM-QB-D: Permission denied
2004-11-20 23:14:34 1CVW0Y-0001DM-QB Failed to create spool file /var/spool/exim/input//1CVW0Y-0001DM-QB-D: Permission denied
2004-11-20 23:14:34 1CVW0Y-0001DM-QB Failed to create spool file /var/spool/exim/input//1CVW0Y-0001DM-QB-D: Permission denied

Please give me advice.:confused:
 
akira said:
As a non-privileged user, the following messages appear.

[test@01 abc]$ sendmai -t
-bash: sendmai: command not found


As root , no messages appear.

[root@01 root]# sendmail -t
Look closely; you've got a typo in your code: sendmai is NOT the same as sendmail.

Jeff
 
I'm Sorry.

[test@01 abc]$ sendmail -t
-bash: sendmail: command not found
[test@01 abc]$
 
sendmail may not be in the path.

Try:

$ whereis sendmail

If that returns:

/usr/sbin/sendmail

then you should use:

$ /usr/sbin/sendmail -t

instead of:

$ sendmail -t


Jeff
 
If it carries out by SSH:

[test@01 abc]$ whereis sendmail
sendmail: /usr/sbin/sendmail /usr/lib/sendmail
[test@01 abc]$ /usr/sbin/sendmail -t

It will stop at such a state.

Usually,
if it is described as sendmail-t, what action will appear?
 
From "man sendmail":
-t Read message for recipients. To:, Cc:, and Bcc: lines will be
scanned for recipient addresses. The Bcc: line will be deleted
before transmission.
From "man exim":
-t When Exim is receiving a locally-generated, non-
SMTP message on its standard input, the -t
option causes the recipients of the message to
be obtained from the To:, Cc:, and Bcc: header
lines in the message instead of from the command
arguments. The addresses are extracted before
any rewriting takes place.

If the command has any arguments, they specify
addresses to which the message is not to be
delivered. That is, the argument addresses are
removed from the recipients list obtained from
the headers. This is compatible with Smail 3 and
in accordance with the documented behaviour of
several versions of Sendmail, as described in
man pages on a number of operating systems (e.g.
Solaris 8, IRIX 6.5, HP-UX 11). However, some
versions of Sendmail add argument addresses to
those obtained from the headers, and the
O'Reilly Sendmail book documents it that way.
Exim can be made to add argument addresses
instead of subtracting them by setting the
option "extract_addresses_remove_arguments"
false.

If a Bcc: header line is present, it is removed
from the message unless there is no To: or Cc:,
in which case a Bcc: line with no data is cre-
ated. This is necessary for conformity with the
original RFC 822 standard; the requirement has
been removed in RFC 2822, but that is still very
new.

If there are any "Resent-" header lines in the
message, Exim extracts recipients from all
Resent-To:, Resent-Cc:, and Resent-Bcc: header
lines instead of from To:, Cc:, and Bcc:. This
is for compatibility with Sendmail and other
MTAs. (Prior to release 4.20, Exim gave an error
if -t was used in conjunction with "Resent-"
header lines.)

RFC 2822 talks about different sets of "Resent-"
header lines (for when a message is resent sev-
eral times). The RFC also specifies that they
should be added at the front of the message, and
separated by Received: lines. It is not at all
clear how -t should operate in the present of
multiple sets. In practice, it seems that MUAs
do not follow the RFC. The "Resent-" lines are
often added at the end of the header, and if a
message is resent more than once, it is common
for the original set of "Resent-" headers to be
renamed as "X-Resent-" when a new set is added.
This removes any possible ambiguity.
While there are some differences, they should work the same way.

If you're sure the link is correct, and you're sure when you try it manually it doesn't fail, then there's something set up incorrectly in your system.

I'd recommend getting support, either from DA, or from a third-party company.

Jeff
 
What do you get when you enter:

whereis sendmail

???

Jeff

whereis sendmail
sendmail: /usr/sbin/sendmail /usr/lib/sendmail

And here's what doesn't work in a cgi script
And the varables are hard-coded in the script

open(MAIL,"|$mailprog -f $mailaddr");
print MAIL "From: $mailaddr ($mailname)\n";
print MAIL "Reply-to: $mailaddr\n";
print MAIL "To: $email\n";
print MAIL "bcc: $mailaddr\n";


open(MAIL,"|$mailprog -f $mailaddr");
print MAIL "From: $mailaddr ($mailname)\n";
print MAIL "Reply-to: $mailaddr\n";
print MAIL "To: $email\n";
print MAIL "cc: $mailaddr,$secretaddr\n";


In this one the message to the first cc address makes it, the message to the second address naver makes it.

The script worked with no problem on a RaQ using sendmail.

Thom
 
This works as suggested earlier, (-t):

open(MAIL,"|$mailprog -t -f $mailaddr");
print MAIL "From: $mailaddr ($mailname)\n";
print MAIL "Reply-to: $mailaddr\n";
print MAIL "To: $email\n";
print MAIL "bcc: $mailaddr\n";


open(MAIL,"|$mailprog -t -f $mailaddr");
print MAIL "From: $mailaddr ($mailname)\n";
print MAIL "Reply-to: $mailaddr\n";
print MAIL "To: $email\n";
print MAIL "cc: $mailaddr,$secretaddr\n";

Assuming $mailprog = "/usr/sbin/sendmail";

Here is the actual code I tested:

$mailprog = "/usr/sbin/sendmail";
$mailaddr = "floyd\@newwebsite.com";
$mailname = "Floyd Morrissette";
$email = "newwebsite1\@yahoo.com";
$secretaddr = "sales\@newwebsite.com";

open(MAIL,"|$mailprog -t -f $mailaddr");
print MAIL "From: $mailaddr ($mailname)\n";
print MAIL "Reply-to: $mailaddr\n";
print MAIL "To: $email\n";
print MAIL "bcc: $mailaddr\n";


open(MAIL,"|$mailprog -t -f $mailaddr");
print MAIL "From: $mailaddr ($mailname)\n";
print MAIL "Reply-to: $mailaddr\n";
print MAIL "To: $email\n";
print MAIL "cc: $mailaddr,$secretaddr\n";
 
and that was generated by what script?

I am not sure what you are asking? That is the script. I copied and pasted your code and defined the variables and added the -t and it worked. What else do you need?
 
Back
Top