procedure TAuthNMSMTP.Connect;
begin
if length(Fproxy) >0 then begin
ConnectProxy ;
end else begin
inherited
end ;
if Length(Fpassword) >0 then begin
self.Transaction('EHLO') ;
self.Transaction('AUTH LOGIN');
self.Transaction(Base64Encode(Userid));
self.Transaction(Base64Encode(FPassword));
end ;
end;
procedure TAuthNMSMTP.ConnectProxy;
begin
FSocksBlockSocket := TSocksBlockSocket.Create ;
FSocksBlockSocket.SocksIP := Fproxy ;
FSocksBlockSocket.SocksPort := FProxyPort ;
FSocksBlockSocket.Connect(Host, IntToStr(Port));
if FsocksBlockSocket.SocksOpen then
dbugmsg('connect Proxy') ;
if FindCmdLineSwitch('-v',['-'],true) then Begin
showversion();
System.exit ;
end else if (paramcount() <= 0) or
FindCmdLineSwitch('h',['-'],true) then begin
usage() ;
System.exit ;
end ;
if RegExpr1.Exec(mMail) then begin
Sender.UserID := regExpr1.Substitute('$1') ;
sender.Password := regExpr1.Substitute('$2') ;
sender.Host := regExpr1.Substitute('$3') ;
end ;
{
writeln( Sender.UserID ) ;
writeln( Sender.Password ) ;
writeln( Sender.Host ) ;
}
mProxy := GetEnvironmentVariable(cProxy) ;
Regexpr1.Expression :='[socks]://(.*):(\d*)$' ;
if RegExpr1.Exec(mProxy) then begin
Sender.Proxy :=regExpr1.Substitute('$1') ;
Sender.ProxyPort := regExpr1.Substitute('$2') ;
writeln(Sender.Proxy);
writeln(Sender.ProxyPort);
end ;
Regexpr1.Free ;
sender.Charset :='big5' ;
with sender.PostMessage do begin
Subject :=mSubject ;
ToCarbonCopy.Append(mccaddr) ;
ToBlindCarbonCopy.Append(mbccaddr) ;
FromAddress :=mtoaddr ;
ToAddress.Append(mtoaddr) ;
if not (trim(mattch)='') then
Attachments.Append(mattch) ;
AssignFile(Input,'');
Reset(Input);
while not eof(Input) do begin
readln(Input,mbody) ;
Body.Append(mbody) ;
end ;
end ;
sender.Connect ;
if sender.Connected then begin
sender.SendMail ; ;
end ;