The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Perl Sendmail Permissions problem

Discussion in 'E-mail Discussions' started by Starcraftmazter, Apr 9, 2009.

  1. Starcraftmazter

    Starcraftmazter Well-Known Member

    Joined:
    May 5, 2006
    Messages:
    47
    Likes Received:
    0
    Trophy Points:
    6
    Hello

    I have a problem where my user(s) cannot utilise sendmail from perl. Any perl script which is supposed to send mail does not do so - but executes fine, without any warnings or errors.

    When running the same scripts from terminal as root, the emails are sent fine - which makes me think it's a permissions related problem.

    The permissions on sendmail look correct though.
    Code:
    -rwxr-sr-x 1 root mailtrap 11937 Mar 17 07:18 sendmail
    Here is an example script:
    Code:
    #!/usr/bin/perl
    use CGI::Carp qw(fatalsToBrowser);
    print "Content-type: text/html\n\n";
    
    $sendmail = "/usr/sbin/sendmail -t";
    $reply_to = "Reply-to: tech.s\@virgin.net\n";
    $subject  = "Subject: Test\n";
    $ccheader = "CC: omalogic\@gmail.com\n";
    $content  = "This is a test.";
    $send_to   = "To: tech.s\@virgin.net\n";
    
    # open(SENDMAIL, "|$sendmail") or die "Cannot open $sendmail: $!";
    open(MAIL, "|$sendmail") || print "Error Opening mail: $!";
    print MAIL $reply_to;
    print MAIL $subject;
    print MAIL $send_to;
    print MAIL $ccheader;
    print MAIL $content;
    close(MAIL);
    
    print "Email Sent\n";
    

    Any suggestions?
    Thanks
     
  2. btwatts

    btwatts Active Member

    Joined:
    Jun 26, 2003
    Messages:
    29
    Likes Received:
    0
    Trophy Points:
    1
    Updates?

    I'm having a similar problem.

    My log file says: sendmail cannot be called directly from a shell with the current user id

    I believe I'm running as suexec nobody

    And apparently nobody can't run sendmail.

    Suggestions?
     
Loading...

Share This Page