나는 cron 작업을 통해 매일 약 5000 건의 전자 메일 (많은 회계 서류)을 보내고 은 단 한 명의 수신자에게 메일을 보낼 때 잘 작동한다.. 문제는 BCC 사본을 활성화 한 다음 앱이 980-1050 개의 메일을 보내기 시작하고 4.5.3
개의 smtp (수신자가 너무 많음) 오류가 발생하기 시작하면 발생합니다. 작업을 일시 중지하고 cron을 다시 실행하면 PHP 프로세스에서 새 PID를 가져 와서 같은 제한 (980-1050 메일)에 도달 할 때까지 확인을 시작합니다.PHP와 Smtp와의 통신
내 질문은 : 거기에 PHP 프로세스 ID를 재생성하는 방법은 무엇입니까?
내가 할 수 있다면, 그때 응용 프로그램은 문제없이 그 메일을 보낼 것입니다.
아니면 일부 후위 구성이 누락 되었습니까?
코드 주요부 다음 "버그"다른 기능 숨은 복사 기능에 참여 결국
/**
* _Send_SmtpData
* Handles the SMTP negotiation for sending the email header and body.
*
* @param String $rcpt_to The 'receipt to' address to send the email to. This is a bare email address only.
* @param String $to The 'to' address to send this to. This can contain a name/email address in the standard format ("Name" <[email protected]>)
* @param String $subject The subject of the email to send.
* @param String $body The body of the email to send.
* @param String $headers The headers of the email to send.
**/
function _Send_SmtpData(&$rcpt_to, &$to, &$subject, &$body, &$headers)
{
$data = "DATA";
$this->DebugMemUsage('Trying to put ' . $data);
if (!$this->_Put_Smtp_Connection($data)) {
$this->ErrorCode = 12;
$this->ErrorCodeSMTPEnhanced = false;
$this->Error = GetLang('UnableToSendEmail_Data');
$this->_Close_Smtp_Connection();
$this->DebugMemUsage('Got error ' . $this->Error);
return array(false, $this->Error);
}
$response = $this->_get_response();
$this->DebugMemUsage('Got response ' . $response);
$responsecode = substr($response, 0, 3);
if ($responsecode != '354') {
$this->ErrorCode = $responsecode;
$this->ErrorCodeSMTPEnhanced = $this->_GetSMTPEnhancedErrorCode($response);
$this->Error = $response;
$this->_Close_Smtp_Connection();
$this->DebugMemUsage('Got error ' . $this->Error);
return array(false, $this->Error);
}
$msg = "To: " . $to . $this->_smtp_newline . "Subject: " . $subject . $this->_smtp_newline . $headers . $this->_smtp_newline . preg_replace('/^\.(\r|\n)/m', ' .${1}', $body);
$msg = str_replace("\r\n","\n",$msg);
$msg = str_replace("\r","\n",$msg);
$lines = explode("\n",$msg);
foreach ($lines as $no => $line) {
// we need to rtrim here so we don't get rid of tabs before the start of the line.
// the tab is extremely important for boundaries (eg sending multipart + attachment)
// so it needs to stay.
$data = rtrim($line);
$this->DebugMemUsage('Trying to put ' . $data);
if (!$this->_Put_Smtp_Connection($data)) {
$this->ErrorCode = 13;
$this->ErrorCodeSMTPEnhanced = false;
$this->Error = GetLang('UnableToSendEmail_DataWriting');
$this->_Close_Smtp_Connection();
$this->DebugMemUsage('Got error ' . $this->Error);
return array(false, $this->Error);
}
}
$data = $this->_smtp_newline . ".";
$this->DebugMemUsage('Trying to put ' . $data);
if (!$this->_Put_Smtp_Connection($data)) {
$this->ErrorCode = 14;
$this->ErrorCodeSMTPEnhanced = false;
$this->Error = GetLang('UnableToSendEmail_DataFinished');
$this->_Close_Smtp_Connection();
$this->DebugMemUsage('Got error ' . $this->Error);
return array(false, $this->Error);
}
$response = $this->_get_response();
$this->DebugMemUsage('Got response ' . $response);
$responsecode = substr($response, 0, 3);
if ($responsecode != '250') {
$this->ErrorCodeSMTPEnhanced = $this->_GetSMTPEnhancedErrorCode($response);
$this->ErrorCode = $responsecode;
$this->Error = $response;
$this->_Close_Smtp_Connection();
$this->DebugMemUsage('Got error ' . $this->Error);
return array(false, $this->Error);
}
$this->DebugMemUsage('Mail accepted ');
/**
* We got this far, this means we didn't encounter any errors.
* Cleanup previous error codes and variables since they are no longer relevant
* with the current process iteration.
*/
$this->Error = '';
$this->ErrorCode = false;
$this->ErrorCodeSMTPEnhanced = false;
$this->_smtp_email_count++;
return array(true, false);
}
어쩌면 코드를 보낼 수 있나요, 송신 루프일까요? –
나는 질문을 우회 할 것이다 ... 기다림 – Hackerman
문제는 무엇보다 응용 프로그램 구조와 관련이있다. – Brad