Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2004
    Location
    Devon, UK
    Posts
    20

    Spot the difference - sendmail

    Hi All,

    Please take a look at the two output streams from a simple perl script below. All I'm trying to do is send a simple plaintext email using sendmail (8.12.4) on redhat 9.

    The first one is my newer server. If I run it with sendmail's verbose switch on (-v) it runs - slightly slow, but it runs. Without the switch, it never seems to end.

    The second one is on another server. It runs lightning fast, with or without the switch. Sendmail is older and it is redhat 7.2.

    Looking for differences, I can see the responses from the smtp service are different like PIPELINING and AUTH etc, but I'm not sure if this is due to the different versions of sendmail or if it's a config issue.

    I'd like my newer server to behave more like the older one, but with one exception. I don't want to relay via another one of our own mail servers (see *** ), but rather deal with the email and get rid of all responsibility.


    [[email protected] rcog]# perl Test2.cgi
    James Fawcett <MyCorrectEmailAddress> ... Connecting to [127.0.0.1] via relay...
    220 linuxNEWmailserver.MyDomain.com ESMTP Sendmail 8.12.8/8.12.8; Tue, 17 May 2005 17:25:04 +0100
    >>> EHLO linuxNEWmailserver.MyDomain.com
    250-linuxNEWmailserver.MyDomain.com Hello localhost.localdomain [127.0.0.1], pleased to meet you
    250-ENHANCEDSTATUSCODES
    250-PIPELINING
    250-8BITMIME
    250-SIZE
    250-DSN
    250-ETRN
    250-AUTH DIGEST-MD5 CRAM-MD5 LOGIN PLAIN
    250-DELIVERBY
    250 HELP
    >>> MAIL From:<[email protected]> SIZE=201 [email protected]
    250 2.1.0 <[email protected]>... Sender ok
    >>> RCPT To:<MyCorrectEmailAddress>
    >>> DATA
    250 2.1.5 <MyCorrectEmailAddress>... Recipient ok
    354 Enter mail, end with "." on a line by itself
    >>> .
    250 2.0.0 j4HGP4R2004352 Message accepted for delivery
    James Fawcett <MyCorrectEmailAddress> ... Sent (j4HGP4R2004352 Message accepted for delivery)
    Closing connection to [127.0.0.1]
    >>> QUIT
    221 2.0.0 linuxNEWmailserver.MyDomain.com closing connection



    [[email protected] web]# perl Test2.cgi
    James Fawcett <MyCorrectEmailAddress> ... Connecting to linuxOLDmailserver.MyDomain.com. *** via relay...
    220 linuxOLDmailserver.MyDomain.com ESMTP Sendmail 8.11.6/8.11.6; Tue, 17 May 2005 17:31:56 +0100
    >>> EHLO linuxwebserver.MyDomain.com
    250-linuxOLDmailserver.MyDomain.com Hello linuxwebserver.MyDomain.com [xxx.yyy.zzz.154], pleased to meet you
    250-ENHANCEDSTATUSCODES
    250-8BITMIME
    250-SIZE
    250-DSN
    250-ONEX
    250-ETRN
    250-XUSR
    250 HELP
    >>> MAIL From:<[email protected]> SIZE=201
    250 2.1.0 <[email protected]>... Sender ok
    >>> RCPT To:<MyCorrectEmailAddress>
    250 2.1.5 <MyCorrectEmailAddress>... Recipient ok
    >>> DATA
    354 Enter mail, end with "." on a line by itself
    >>> .
    250 2.0.0 j4HGVuN03671 Message accepted for delivery
    James Fawcett <MyCorrectEmailAddress> ... Sent (j4HGVuN03671 Message accepted for delivery)
    Closing connection to linuxOLDmailserver.MyDomain.com.
    >>> QUIT
    221 2.0.0 linuxOLDmailserver.MyDomain.com closing connection

  2. Without seeing your code I can't really debug it very well, but as for:

    I don't want to relay via another one of our own mail servers...
    you can use this format:

    #!/usr/local/bin/perl -w

    $|++;
    use strict;
    use Mail:endmail;

    my $to = [email protected]';
    my $from = "$ENV{USER}\@yourdomain.com";
    my $subject = "Hi";
    my $message = "How's it goin'?\n\n-Me";

    mail_it($to,$from,$subject,$message);

    sub mail_it {
    my %mail_hash = (
    To => $_[0],
    From => $_[1],
    Subject => $_[2],
    Message => $_[3]
    );
    sendmail(%mail_hash);
    }


    the $|++ may even solve your issue, I know it has solved many IO issues I've had.

    You may have to install Mail:endmail, if this is a FreeBSD system you can make install from port /usr/ports/mail/p5-Mail-Sendmail

    Of course, the above sample is very simplistic, it can be modified many ways so that dynamic data can be used.
    Last edited by Network Forums; 05-18-2005 at 09:20 AM.

  3. #3
    Join Date
    Apr 2004
    Location
    Devon, UK
    Posts
    20
    Thanks,

    This is what I had before:

    #!/usr/bin/perl

    open (MAIL, "|/usr/sbin/sendmail -vt") || die("Can't open $MailProg!\n");
    print MAIL "From: LinuxMail01 <support\@MyDomain.com> \n";
    print MAIL "To: James Fawcett <jfawcett\@MyDomain.com> \n";
    print MAIL "Reply-to: LinuxMail01 <support\@MyDomain.com> \n";
    print MAIL "Subject: Test email \n";
    print MAIL "Content-type: text/plain \n\n";
    print MAIL <<_EOOpenText_;

    Test email

    _EOOpenText_

    close(MAIL);
    exit 0;

    I'm no expert programmer by any means, but I know the code works. The main concern is the time it takes run it on the newer server (first output) and the fact that if I remove the -v from sendmail, it hangs altogether.

    Any ideas about that?

    Thanks

  4. Actually, I might.

    Sendmail, when run from the command line, knows you are done when you put a single period "." on a line by itself. I don't see you printing that to the sendmail process you invoked.

    Try adding this right above "close(MAIL);":

    print MAIL ".\n";


    Hope that works

  5. #5
    Join Date
    Apr 2004
    Location
    Devon, UK
    Posts
    20
    No, that didn't make any difference.

    Does anyone know about those responses: PIPELINING, AUTH, etc. Which ones need to be there, which ones are optional, etc?

    Thanks

  6. #6
    Join Date
    Apr 2004
    Location
    Devon, UK
    Posts
    20
    In fact the message does actually get sent. But the script doesn't finish. This happened before introducing the print MAIL ".\n";

  7. I have two suggestions left:

    1) Change:

    #!/usr/bin/perl

    to:

    #!/usr/bin/perl -w


    This will give you additional error output, if there is any.

    2) Add:

    $|++;

    below the #!/usr/bin/perl -w line, this will eliminate buffering and could potentially solve hidden conflicts with the command line invocation.

  8. #8
    Join Date
    Apr 2004
    Location
    Devon, UK
    Posts
    20
    Well, I tried that, but it made no difference.

    Thanks though.

    I'm leaning towards thinking it's a name resolution issue or smtp authentication issue.

    Anyone got any expertise in this?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •