Revision 847673ae
Added by Carlos Eduardo Ramos about 15 years ago
etc/inc/smtp.inc | ||
---|---|---|
89 | 89 |
{ |
90 | 90 |
$status=socket_get_status($this->connection); |
91 | 91 |
if($status["timed_out"]) |
92 |
$this->error.=": data access time out";
|
|
92 |
$this->error.=gettext(": data access time out");
|
|
93 | 93 |
elseif($status["eof"]) |
94 | 94 |
{ |
95 |
$this->error.=": the server disconnected";
|
|
95 |
$this->error.=gettext(": the server disconnected");
|
|
96 | 96 |
$this->disconnected_error=1; |
97 | 97 |
} |
98 | 98 |
} |
... | ... | |
104 | 104 |
{ |
105 | 105 |
if(feof($this->connection)) |
106 | 106 |
{ |
107 |
$this->error="reached the end of data while reading from the SMTP server conection";
|
|
107 |
$this->error=gettext("reached the end of data while reading from the SMTP server conection");
|
|
108 | 108 |
return(""); |
109 | 109 |
} |
110 | 110 |
if(GetType($data=@fgets($this->connection,100))!="string" |
111 | 111 |
|| strlen($data)==0) |
112 | 112 |
{ |
113 |
$this->SetDataAccessError("it was not possible to read line from the SMTP server");
|
|
113 |
$this->SetDataAccessError(gettext("it was not possible to read line from the SMTP server"));
|
|
114 | 114 |
return(""); |
115 | 115 |
} |
116 | 116 |
$line.=$data; |
... | ... | |
132 | 132 |
$this->OutputDebug("C $line"); |
133 | 133 |
if(!@fputs($this->connection,"$line\r\n")) |
134 | 134 |
{ |
135 |
$this->SetDataAccessError("it was not possible to send a line to the SMTP server");
|
|
135 |
$this->SetDataAccessError(gettext("it was not possible to send a line to the SMTP server"));
|
|
136 | 136 |
return(0); |
137 | 137 |
} |
138 | 138 |
return(1); |
... | ... | |
146 | 146 |
$this->OutputDebug("C $data"); |
147 | 147 |
if(!@fputs($this->connection,$data)) |
148 | 148 |
{ |
149 |
$this->SetDataAccessError("it was not possible to send data to the SMTP server");
|
|
149 |
$this->SetDataAccessError(gettext("it was not possible to send data to the SMTP server"));
|
|
150 | 150 |
return(0); |
151 | 151 |
} |
152 | 152 |
} |
... | ... | |
218 | 218 |
$version=explode(".",function_exists("phpversion") ? phpversion() : "3.0.7"); |
219 | 219 |
$php_version=intval($version[0])*1000000+intval($version[1])*1000+intval($version[2]); |
220 | 220 |
if($php_version<4003000) |
221 |
return("establishing SSL connections requires at least PHP version 4.3.0");
|
|
221 |
return(gettext("establishing SSL connections requires at least PHP version 4.3.0"));
|
|
222 | 222 |
if(!function_exists("extension_loaded") |
223 | 223 |
|| !extension_loaded("openssl")) |
224 |
return("establishing SSL connections requires the OpenSSL extension enabled");
|
|
224 |
return(gettext("establishing SSL connections requires the OpenSSL extension enabled"));
|
|
225 | 225 |
} |
226 | 226 |
if(ereg('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$',$domain)) |
227 | 227 |
$ip=$domain; |
... | ... | |
230 | 230 |
if($this->debug) |
231 | 231 |
$this->OutputDebug($resolve_message); |
232 | 232 |
if(!strcmp($ip=@gethostbyname($domain),$domain)) |
233 |
return("could not resolve host \"".$domain."\"");
|
|
233 |
return(sprintf(gettext("could not resolve host \"%s\""), $domain));
|
|
234 | 234 |
} |
235 | 235 |
if(strlen($this->exclude_address) |
236 | 236 |
&& !strcmp(@gethostbyname($this->exclude_address),$ip)) |
237 |
return("domain \"".$domain."\" resolved to an address excluded to be valid");
|
|
237 |
return(sprintf(gettext("domain \"%s\" resolved to an address excluded to be valid"), $domain));
|
|
238 | 238 |
if($this->debug) |
239 |
$this->OutputDebug("Connecting to host address \"".$ip."\" port ".$port."...");
|
|
239 |
$this->OutputDebug(sprintf(gettext("Connecting to host address \"%s\" port %s..."), $ip, $port));
|
|
240 | 240 |
if(($this->connection=($this->timeout ? @fsockopen(($this->ssl ? "ssl://" : "").$ip,$port,$errno,$error,$this->timeout) : @fsockopen(($this->ssl ? "ssl://" : "").$ip,$port)))) |
241 | 241 |
return(""); |
242 | 242 |
$error=($this->timeout ? strval($error) : "??"); |
243 | 243 |
switch($error) |
244 | 244 |
{ |
245 | 245 |
case "-3": |
246 |
return("-3 socket could not be created");
|
|
246 |
return(gettext("-3 socket could not be created"));
|
|
247 | 247 |
case "-4": |
248 |
return("-4 dns lookup on hostname \"".$domain."\" failed");
|
|
248 |
return(sprintf(gettext("-4 dns lookup on hostname \"%s\" failed"), $domain));
|
|
249 | 249 |
case "-5": |
250 |
return("-5 connection refused or timed out");
|
|
250 |
return(gettext("-5 connection refused or timed out"));
|
|
251 | 251 |
case "-6": |
252 |
return("-6 fdopen() call failed");
|
|
252 |
return(gettext("-6 fdopen() call failed"));
|
|
253 | 253 |
case "-7": |
254 |
return("-7 setvbuf() call failed");
|
|
254 |
return(gettext("-7 setvbuf() call failed"));
|
|
255 | 255 |
} |
256 |
return("could not connect to the host \"".$domain."\": ".$error);
|
|
256 |
return(sprintf(gettext("could not connect to the host \"%s\": %s"), $domain, $error));
|
|
257 | 257 |
} |
258 | 258 |
|
259 | 259 |
Function SASLAuthenticate($mechanisms, $credentials, &$authenticated, &$mechanism) |
... | ... | |
262 | 262 |
if(!function_exists("class_exists") |
263 | 263 |
|| !class_exists("sasl_client_class")) |
264 | 264 |
{ |
265 |
$this->error="it is not possible to authenticate using the specified mechanism because the SASL library class is not loaded";
|
|
265 |
$this->error=gettext("it is not possible to authenticate using the specified mechanism because the SASL library class is not loaded");
|
|
266 | 266 |
return(0); |
267 | 267 |
} |
268 | 268 |
$sasl=new sasl_client_class; |
... | ... | |
286 | 286 |
case SASL_NOMECH: |
287 | 287 |
if(strlen($this->authentication_mechanism)) |
288 | 288 |
{ |
289 |
$this->error="authenticated mechanism ".$this->authentication_mechanism." may not be used: ".$sasl->error;
|
|
289 |
$this->error=printf(gettext("authenticated mechanism %s may not be used: %s"), $this->authentication_mechanism, $sasl->error);
|
|
290 | 290 |
return(0); |
291 | 291 |
} |
292 | 292 |
break; |
293 | 293 |
default: |
294 |
$this->error="Could not start the SASL authentication client: ".$sasl->error;
|
|
294 |
$this->error=gettext("Could not start the SASL authentication client:") . " ".$sasl->error;
|
|
295 | 295 |
return(0); |
296 | 296 |
} |
297 | 297 |
if(strlen($mechanism=$sasl->mechanism)) |
298 | 298 |
{ |
299 | 299 |
if($this->PutLine("AUTH ".$sasl->mechanism.(IsSet($message) ? " ".base64_encode($message) : ""))==0) |
300 | 300 |
{ |
301 |
$this->error="Could not send the AUTH command";
|
|
301 |
$this->error=gettext("Could not send the AUTH command");
|
|
302 | 302 |
return(0); |
303 | 303 |
} |
304 | 304 |
if(!$this->VerifyResultLines(array("235","334"),$responses)) |
... | ... | |
313 | 313 |
$response=base64_decode($responses[0]); |
314 | 314 |
break; |
315 | 315 |
default: |
316 |
$this->error="Authentication error: ".$responses[0];
|
|
316 |
$this->error=gettext("Authentication error:") . " ".$responses[0];
|
|
317 | 317 |
return(0); |
318 | 318 |
} |
319 | 319 |
for(;!$authenticated;) |
... | ... | |
328 | 328 |
case SASL_CONTINUE: |
329 | 329 |
if($this->PutLine(base64_encode($message))==0) |
330 | 330 |
{ |
331 |
$this->error="Could not send the authentication step message";
|
|
331 |
$this->error=gettext("Could not send the authentication step message");
|
|
332 | 332 |
return(0); |
333 | 333 |
} |
334 | 334 |
if(!$this->VerifyResultLines(array("235","334"),$responses)) |
... | ... | |
343 | 343 |
$response=base64_decode($responses[0]); |
344 | 344 |
break; |
345 | 345 |
default: |
346 |
$this->error="Authentication error: ".$responses[0];
|
|
346 |
$this->error=gettext("Authentication error:") . " ".$responses[0];
|
|
347 | 347 |
return(0); |
348 | 348 |
} |
349 | 349 |
break; |
350 | 350 |
default: |
351 |
$this->error="Could not process the SASL authentication step: ".$sasl->error;
|
|
351 |
$this->error=gettext("Could not process the SASL authentication step:") . " ".$sasl->error;
|
|
352 | 352 |
return(0); |
353 | 353 |
} |
354 | 354 |
} |
... | ... | |
362 | 362 |
{ |
363 | 363 |
if(strcmp($this->state,"Disconnected")) |
364 | 364 |
{ |
365 |
$this->error="connection is already established";
|
|
365 |
$this->error=gettext("connection is already established");
|
|
366 | 366 |
return(0); |
367 | 367 |
} |
368 | 368 |
$this->disconnected_error=0; |
... | ... | |
400 | 400 |
$user=$this->user; |
401 | 401 |
if(strlen($user)==0) |
402 | 402 |
{ |
403 |
$this->error="it was not specified the POP3 authentication user";
|
|
403 |
$this->error=gettext("it was not specified the POP3 authentication user");
|
|
404 | 404 |
return(0); |
405 | 405 |
} |
406 | 406 |
$password=$this->password; |
407 | 407 |
if(strlen($password)==0) |
408 | 408 |
{ |
409 |
$this->error="it was not specified the POP3 authentication password";
|
|
409 |
$this->error=gettext("it was not specified the POP3 authentication password");
|
|
410 | 410 |
return(0); |
411 | 411 |
} |
412 | 412 |
$domain=$this->pop3_auth_host; |
413 |
$this->error=$this->ConnectToHost($domain, $this->pop3_auth_port, "Resolving POP3 authentication host \"".$domain."\"...");
|
|
413 |
$this->error=$this->ConnectToHost($domain, $this->pop3_auth_port, sprintf(gettext("Resolving POP3 authentication host \"%s\"..."), $domain));
|
|
414 | 414 |
if(strlen($this->error)) |
415 | 415 |
return(0); |
416 | 416 |
if(strlen($response=$this->GetLine())==0) |
417 | 417 |
return(0); |
418 | 418 |
if(strcmp($this->Tokenize($response," "),"+OK")) |
419 | 419 |
{ |
420 |
$this->error="POP3 authentication server greeting was not found";
|
|
420 |
$this->error=gettext("POP3 authentication server greeting was not found");
|
|
421 | 421 |
return(0); |
422 | 422 |
} |
423 | 423 |
if(!$this->PutLine("USER ".$this->user) |
... | ... | |
425 | 425 |
return(0); |
426 | 426 |
if(strcmp($this->Tokenize($response," "),"+OK")) |
427 | 427 |
{ |
428 |
$this->error="POP3 authentication user was not accepted: ".$this->Tokenize("\r\n");
|
|
428 |
$this->error=gettext("POP3 authentication user was not accepted:") . " ".$this->Tokenize("\r\n");
|
|
429 | 429 |
return(0); |
430 | 430 |
} |
431 | 431 |
if(!$this->PutLine("PASS ".$password) |
... | ... | |
433 | 433 |
return(0); |
434 | 434 |
if(strcmp($this->Tokenize($response," "),"+OK")) |
435 | 435 |
{ |
436 |
$this->error="POP3 authentication password was not accepted: ".$this->Tokenize("\r\n");
|
|
436 |
$this->error=gettext("POP3 authentication password was not accepted:") . " ".$this->Tokenize("\r\n");
|
|
437 | 437 |
return(0); |
438 | 438 |
} |
439 | 439 |
fclose($this->connection); |
... | ... | |
442 | 442 |
} |
443 | 443 |
if(count($hosts)==0) |
444 | 444 |
{ |
445 |
$this->error="could not determine the SMTP to connect";
|
|
445 |
$this->error=gettext("could not determine the SMTP to connect");
|
|
446 | 446 |
return(0); |
447 | 447 |
} |
448 | 448 |
for($host=0, $error="not connected";strlen($error) && $host<count($hosts);$host++) |
449 | 449 |
{ |
450 | 450 |
$domain=$hosts[$host]; |
451 |
$error=$this->ConnectToHost($domain, $this->host_port, "Resolving SMTP server domain \"$domain\"...");
|
|
451 |
$error=$this->ConnectToHost($domain, $this->host_port, sprintf(gettext("Resolving SMTP server domain \"%s\"..."), $domain));
|
|
452 | 452 |
} |
453 | 453 |
if(strlen($error)) |
454 | 454 |
{ |
... | ... | |
460 | 460 |
&& function_exists("socket_set_timeout")) |
461 | 461 |
socket_set_timeout($this->connection,$timeout,0); |
462 | 462 |
if($this->debug) |
463 |
$this->OutputDebug("Connected to SMTP server \"".$domain."\".");
|
|
463 |
$this->OutputDebug(sprintf(gettext("Connected to SMTP server \"%s\"."), $domain));
|
|
464 | 464 |
if(!strcmp($localhost=$this->localhost,"") |
465 | 465 |
&& !strcmp($localhost=getenv("SERVER_NAME"),"") |
466 | 466 |
&& !strcmp($localhost=getenv("HOST"),"")) |
... | ... | |
514 | 514 |
{ |
515 | 515 |
if(!IsSet($this->esmtp_extensions["AUTH"])) |
516 | 516 |
{ |
517 |
$this->error="server does not require authentication";
|
|
517 |
$this->error=gettext("server does not require authentication");
|
|
518 | 518 |
$success=0; |
519 | 519 |
} |
520 | 520 |
else |
... | ... | |
578 | 578 |
if($success |
579 | 579 |
&& strlen($mechanism)==0) |
580 | 580 |
{ |
581 |
$this->error="it is not supported any of the authentication mechanisms required by the server";
|
|
581 |
$this->error=gettext("it is not supported any of the authentication mechanisms required by the server");
|
|
582 | 582 |
$success=0; |
583 | 583 |
} |
584 | 584 |
} |
... | ... | |
610 | 610 |
$sender=$this->direct_sender; |
611 | 611 |
break; |
612 | 612 |
default: |
613 |
$this->error="direct delivery connection is already established and sender is already set";
|
|
613 |
$this->error=gettext("direct delivery connection is already established and sender is already set");
|
|
614 | 614 |
return(0); |
615 | 615 |
} |
616 | 616 |
} |
... | ... | |
618 | 618 |
{ |
619 | 619 |
if(strcmp($this->state,"Connected")) |
620 | 620 |
{ |
621 |
$this->error="connection is not in the initial state";
|
|
621 |
$this->error=gettext("connection is not in the initial state");
|
|
622 | 622 |
return(0); |
623 | 623 |
} |
624 | 624 |
} |
... | ... | |
640 | 640 |
if($this->direct_delivery) |
641 | 641 |
{ |
642 | 642 |
if(GetType($at=strrpos($recipient,"@"))!="integer") |
643 |
return("it was not specified a valid direct recipient");
|
|
643 |
return(gettext("it was not specified a valid direct recipient"));
|
|
644 | 644 |
$domain=substr($recipient,$at+1); |
645 | 645 |
switch($this->state) |
646 | 646 |
{ |
... | ... | |
659 | 659 |
case "RecipientSet": |
660 | 660 |
if(strcmp($this->connected_domain,$domain)) |
661 | 661 |
{ |
662 |
$this->error="it is not possible to deliver directly to recipients of different domains";
|
|
662 |
$this->error=gettext("it is not possible to deliver directly to recipients of different domains");
|
|
663 | 663 |
return(0); |
664 | 664 |
} |
665 | 665 |
break; |
666 | 666 |
default: |
667 |
$this->error="connection is already established and the recipient is already set";
|
|
667 |
$this->error=gettext("connection is already established and the recipient is already set");
|
|
668 | 668 |
return(0); |
669 | 669 |
} |
670 | 670 |
} |
... | ... | |
676 | 676 |
case "RecipientSet": |
677 | 677 |
break; |
678 | 678 |
default: |
679 |
$this->error="connection is not in the recipient setting state";
|
|
679 |
$this->error=gettext("connection is not in the recipient setting state");
|
|
680 | 680 |
return(0); |
681 | 681 |
} |
682 | 682 |
} |
... | ... | |
705 | 705 |
{ |
706 | 706 |
if(strcmp($this->state,"RecipientSet")) |
707 | 707 |
{ |
708 |
$this->error="connection is not in the start sending data state";
|
|
708 |
$this->error=gettext("connection is not in the start sending data state");
|
|
709 | 709 |
return(0); |
710 | 710 |
} |
711 | 711 |
$this->error=""; |
... | ... | |
735 | 735 |
{ |
736 | 736 |
if(strcmp($this->state,"SendingData")) |
737 | 737 |
{ |
738 |
$this->error="connection is not in the sending data state";
|
|
738 |
$this->error=gettext("connection is not in the sending data state");
|
|
739 | 739 |
return(0); |
740 | 740 |
} |
741 | 741 |
$this->error=""; |
... | ... | |
746 | 746 |
{ |
747 | 747 |
if(strcmp($this->state,"SendingData")) |
748 | 748 |
{ |
749 |
$this->error="connection is not in the sending data state";
|
|
749 |
$this->error=gettext("connection is not in the sending data state");
|
|
750 | 750 |
return(0); |
751 | 751 |
} |
752 | 752 |
$this->error=""; |
... | ... | |
782 | 782 |
{ |
783 | 783 |
if(!strcmp($this->state,"Disconnected")) |
784 | 784 |
{ |
785 |
$this->error="it was not previously established a SMTP connection";
|
|
785 |
$this->error=gettext("it was not previously established a SMTP connection");
|
|
786 | 786 |
return(0); |
787 | 787 |
} |
788 | 788 |
$this->error=""; |
... | ... | |
840 | 840 |
|
841 | 841 |
}; |
842 | 842 |
|
843 |
?> |
|
843 |
?> |
Also available in: Unified diff
Implement gettext() calls on smtp.inc