Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Dec 2005
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Help! Our upload script can't send mail notifications anymore

    In order to speed up our WP site, our host recently changed us to suPHP. Unfortunately, we have an upload script that we can't live without, that is no longer sending us email notifications. Here's the error:

    $* is no longer supported at /***/***/upload.cgi line 1022.
    sendmail: sendmail cannot be called directly from a shell with the current user id
    So it looks like we'll need to use smtp auth to send mail from the script. However, the original developer has abandoned support for this script, and my knowledge of Perl is limited.

    I've asked in another forum, but the script is in Perl, which they weren't too familiar with. Is there a Pear Guru here who can help me edit this portion of the script so it can send mail notifications again?

    Below is the portion of the script that sends mail. Any help greatly appreciated!

    Code:
    sub send_mail_NT {
    my ( %VAR, @atts ); 
    
    $VAR{sndrEml} = shift;
    $VAR{sndrNme} = shift;
    $VAR{rcvrEml} = shift;
    $VAR{rcvrNme} = shift;
    $VAR{subject} = shift;
    $VAR{message} = shift;
    $VAR{ccrcEml} = shift;
    $VAR{ccrcNme} = shift;
    
    use Socket;
    
    $VAR{CRLF} = "\015\012";
    $VAR{debug} = 0;
    
    if($VAR{debug}){
    #BEGIN { 
    #$| = 1;
    #open (STDERR, ">&STDOUT");
    #print qq~Content-type: text/html\n\n<pre>~;
    #}
    }
    
    $VAR{message} =~ s/\r+//ig;
    $VAR{message} =~ s/\n{3,300}/$VAR{CRLF}$VAR{CRLF}/ig;
    $VAR{message} =~ s/\n/$VAR{CRLF}/ig;
    $VAR{attPths} =~ s/\s+//ig;
    
    $VAR{HTMLmess} = $VAR{message};
    $VAR{TEXTmess} = $VAR{message};
    if($CONFIG{mail_format} == 2){
    $VAR{TEXTmess} =~ s/\&quot;/\"/g;
    $VAR{TEXTmess} =~ s/\&lt;/\</ig;
    }
    $VAR{files} = qq~~;
    $VAR{hasAtts} = 0;
    
    $VAR{bound1} = qq~----=_NextPart_P_115Dream~; # printable
    $VAR{bound2} = qq~----=_NextPart_A_SubHB~; # attachments
    $VAR{bound3} = qq~----=_NextPart_E_SlowTrain~; # embded
    
    $VAR{fm} = $VAR{sndrNme} =~ /\w+/ ? qq~$VAR{sndrEml} ($VAR{sndrNme})~ : $VAR{sndrEml};
    $VAR{to} = $VAR{rcvrNme} =~ /\w+/ ? qq~$VAR{rcvrEml} ($VAR{rcvrNme})~ : $VAR{rcvrEml};
    $VAR{cc} = $VAR{ccrcNme} =~ /\w+/ ? qq~$VAR{ccrcEml} ($VAR{ccrcNme})~ : $VAR{ccrcEml};
    
    $* = 1; # Set regex to handle multiple line strings
    $VAR{SMTPserver} = $CONFIG{mailprogram};
    $VAR{SMTPport} = 25;
    $VAR{Stream} = $] > 5 ? SOCK_STREAM : 1;
    $VAR{AFinet} = $] > 5 ? AF_INET : 2;
    
    $VAR{protocol} = (getprotobyname('tcp'))[2];
    $VAR{hostName} = (gethostbyname($VAR{SMTPserver}))[4];
    
    $VAR{bindSock} = pack('S n a4 x8', $VAR{AFinet}, 0, $VAR{hostName});
    $VAR{connSock} = pack('S n a4 x8', $VAR{AFinet}, $VAR{SMTPport}, $VAR{hostName});
    
    unless(socket(M, $VAR{AFinet}, $VAR{Stream}, $VAR{protocol})){
    if($VAR{debug}){ print qq~No socket established\n\n~; } return;
    }
    
    bind(M, $VAR{bindSock});
    
    unless(connect(M, $VAR{connSock})){
    if($VAR{debug}){ print qq~No connection established\n\n~; } return;
    }
    
    $VAR{selected} = select(M); $| = 1; select($VAR{selected});
    
    select(undef, undef, undef, 1);
    sysread(M, $_, 1024);
    if($VAR{debug}){ print qq~Connection accepted:$_ \n\n~; }
    
    print M qq~HELO $VAR{SMTPserver}$VAR{CRLF}~;
    sysread(M, $_, 1024);
    if($VAR{debug}){ print qq~HELO:$_ \n\n~; }
    if(!/^\s*250/){ if($VAR{debug}){ print qq~HELO failed\n\n~;} return; }
    
    # authenticate ourselves?
    if($CONFIG{mailuser} =~ /\w+/ && $CONFIG{mailpass} =~ /\w+/){
    $VAR{SMTPuser} = $CONFIG{mailuser};
    $VAR{SMTPpass} = $CONFIG{mailpass};
    
    $VAR{length} = $VAR{SMTPuser};
    $VAR{encoded} = substr(pack('u57', $VAR{SMTPuser}), 1); chop($VAR{encoded});
    $VAR{encoded} =~ tr| -_`|A-Za-z0-9+/A|;
    $VAR{buff} = (3 - ($VAR{length} % 3)) % 3;
    substr($VAR{encoded}, -$VAR{buff}, $VAR{buff}) = '=' x $VAR{buff};
    $VAR{SMTPuser} = $VAR{encoded};
    
    $VAR{length} = $VAR{SMTPpass};
    $VAR{encoded} = substr(pack('u57', $VAR{SMTPpass}), 1); chop($VAR{encoded});
    $VAR{encoded} =~ tr| -_`|A-Za-z0-9+/A|;
    $VAR{buff} = (3 - ($VAR{length} % 3)) % 3;
    substr($VAR{encoded}, -$VAR{buff}, $VAR{buff}) = '=' x $VAR{buff};
    $VAR{SMTPpass} = $VAR{encoded};
    
    print M qq~AUTH LOGIN$VAR{CRLF}~;
    sysread(M, $_, 1024);
    if($VAR{debug}){ print qq~AUTH LOGIN: $_\n\n~; }
    
    print M qq~$VAR{SMTPuser}$VAR{CRLF}~;
    sysread(M, $_, 1024);
    if($VAR{debug}){ print qq~Auth Username: $_\n\n~; }
    
    print M qq~$VAR{SMTPpass}$VAR{CRLF}~;
    sysread(M, $_, 1024);
    if($VAR{debug}){ print qq~Auth Password: $_\n\n~; }
    }
    
    print M qq~MAIL FROM:$VAR{sndrEml}$VAR{CRLF}~;
    sysread(M, $_, 1024);
    if($VAR{debug}){ print qq~MAIL FROM:$_\n\n~; }
    if(!/[^0-9]*250/){ if($VAR{debug}){ print qq~Denied.\n\n~; } return; }
    
    print M qq~RCPT TO:$VAR{rcvrEml}$VAR{CRLF}~;
    sysread(M, $_, 1024); /[^0-9]*(\d\d\d)/;
    if($VAR{debug}){ print qq~RCPT TO:$_\n\n~; }
    if(!/[^0-9]*250/){ if($VAR{debug}){ print qq~Denied. Auth required?\n\n~; } return; }
    
    if($VAR{ccrcEml}){
    print M qq~RCPT TO:$VAR{ccrcEml}$VAR{CRLF}~;
    sysread(SMTP, $_, 1024); /[^0-9]*(\d\d\d)/;
    if($VAR{debug}){ print qq~RCPT TO CC:$_\n\n~; }
    if(!/[^0-9]*250/){ if($VAR{debug}){ print qq~Denied. Auth required?\n\n~; } return; }
    }
    
    print M qq~DATA$VAR{CRLF}~;
    sysread(M, $_, 1024);
    if($VAR{debug}){ print qq~Ready to send DATA:$_\n\n~; }
    if(!/[^0-9]*354/){ if($VAR{debug}){ print qq~Denied.\n\n~; } return; }
    
    print M qq~From: $VAR{fm}$VAR{CRLF}~;
    print M qq~To: $VAR{to}$VAR{CRLF}~;
    print M qq~CC: $VAR{cc}$VAR{CRLF}~ if $VAR{ccrcEml};
    print M qq~Subject: $VAR{subject}$VAR{CRLF}~;
    print M qq~MIME-Version: 1.0$VAR{CRLF}~;
    
    if($CONFIG{mail_format} == 1){
    print M qq~$VAR{fileHeaders}~;
    print M qq~$VAR{embedHeaders}~;
    
    print M qq~Content-Type: multipart/alternative;$VAR{CRLF}~;
    print M qq~\tboundary="$VAR{bound1}"$VAR{CRLF}$VAR{CRLF}$VAR{CRLF}~;
    print M qq~--$VAR{bound1}$VAR{CRLF}~;
    print M qq~Content-Type: text/plain;$VAR{CRLF}~;
    print M qq~Content-Transfer-Encoding: 7bit$VAR{CRLF}$VAR{CRLF}~;
    print M qq~$VAR{TEXTmess}$VAR{CRLF}$VAR{CRLF}~;
    
    print M qq~--$VAR{bound1}$VAR{CRLF}~;
    print M qq~Content-Type: text/html; $VAR{charset2}$VAR{CRLF}$VAR{CRLF}~;
    
    print M qq~$VAR{HTMLmess}$VAR{CRLF}~;
    
    print M qq~$VAR{CRLF}$VAR{CRLF}--$VAR{bound1}--$VAR{files}~;
    } else {
    print M qq~$VAR{fileHeaders}~;
    print M qq~Content-Type: text/plain;$VAR{CRLF}~;
    print M qq~Content-Transfer-Encoding: 7bit$VAR{CRLF}$VAR{CRLF}~;
    print M qq~$VAR{TEXTmess}$VAR{CRLF}$VAR{CRLF}$VAR{files}~;
    }
    
    print M qq~$VAR{CRLF}.$VAR{CRLF}~;
    sysread(M, $_, 1024);
    if($VAR{debug}){ print qq~Message ended:$_\n\n~; }
    if(!/[^0-9]*250/){ if($VAR{debug}){ print qq~Message failed.\n\n~; } return; }
    
    if(!shutdown(M, 2)){
    if($VAR{debug}){ print qq~Shutdown failed:$_\n\n~; } return;
    } else { return 1; }
    }

  2. #2
    New Coder
    Join Date
    May 2015
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You need to enable mta_start_script path in /etc/rc.conf file.


 

Tags for this Thread

Posting Permissions

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