들어오는 메일에 내용 필터를 지정할 수 있습니다. 다음과 같이 master.cf 파일을 수정해야합니다 방법 :
...
smtp inet n - n - - smtpd
...
-o content_filter=yourfilter:
...
yourfilter unix - n n - - pipe
user=[user on which the script will be executed]
argv=php /path/to/your/script.php --sender='${sender}' --recipient='${recipient}'
다음 제대로 제공 된 매개 변수를 사용에서이 메일을 것이라는 방식으로이 script.php를 작성해야합니다 (--sender = ... 그리고 --recipient = ...) mailbody는 stdin에서 제공 될 것입니다. 여기
은 표준 입력에서 이메일을 수있는 방법을 예입니다 (I가 나중에 사용하기 젠드 \ 메일 \ 메시지에서이 하나를 사용 :: fromString()는 메시지 개체를 만들 수) : 파라미터의 지정에 따라
/**
* Retrieves raw message from standard input
* @throws \RuntimeException if calling controller was not executed on console
* @return string raw email message retrieved from standard input
*/
protected function retrieveMessageFromStdin() {
$request = $this->getRequest();
if (!$request instanceof ConsoleRequest)
throw new \RuntimeException('Action can be used only as console action !');
$stdin = fopen('php://stdin', 'r');
$mail_contents = "";
while (!feof($stdin)) {
$line = fread($stdin, 1024);
$mail_contents .= $line;
}
fclose($stdin);
$mail_contents = preg_replace('~\R~u', "\r\n", $mail_contents);
return $mail_contents;
}
을 - 저는 ZF2를 사용하여 거기에 콘솔 어플리케이션을 작성하는 방법이나 프레임 워크에보다 적합한 여러 가지 기술을 사용하는 방법을 읽어야합니다.
메일에서 메일을 받기를 원한다면 이메일을 "postject"로 다시 보내야합니다. 내가하는 방법은 다음과 같습니다.
/**
* Reinjects message to sendmail queue
*
* @param array $senders array of senders to be split into several sender addresses passed to sendmail (in most cases it is only 1 address)
* @param array $recipients array of recipients to be split into several recipient addresses passed to sendmail
* @param string $sendmaiLocation sendmailLocation string full path for sendmail (should be taken from config file)
* @return number return value for sendmail
*/
public function reinject(array $senders, array $recipients, string $sendmaiLocation) {
foreach ($senders as $addresses)
$senderAddress .= " " . $addresses;
foreach ($recipients as $addresses)
$recipientAddress .= " " . $addresses;
$sendmail = $sendmaiLocation . " -G -i -f '" . $senderAddress . "' -- '" . $recipientAddress . "'";
$handle = popen($sendmail, 'w');
fwrite($handle, $this->toString());
return pclose($handle);
}
기본적으로 위 기능을 사용하여 필요에 따라 사용자 지정할 수 있습니다. 그런 다음 앞서 언급 한 명령 줄 매개 변수의 매개 변수를 사용하여 나중에 실행할 수 있습니다.
희망 사항 :
1) "프로세스"란 무엇을 의미합니까? 1a) see/read 1b) rewrite 1c) ... 2) "postfix"솔루션에만 관심이 있습니까? – AnFi
나는 Postfix 문서를 읽은 채로 필자가 원하는 것에 가장 근접한 기능으로'filters'를 발견했습니다. 필자의 요구 사항을 명확히하기 위해 Postfix 용 PHP 스크립트를 설정하여 전자 메일이 발송 될 때마다 해당 전자 메일의 사본이 내 스크립트로 전송되도록하고 싶습니다. Postfix에서 필터를 사용하면 문제가 발생하지만 Postfix의 전달 프로세스의 일부로 문제가 발생합니다. 즉, 내 스크립트가 어떤 이유에서든 이메일을 전달하지 못하면 이메일이 전송되지 않습니다. 내가 원하지 않는 것 (너무 많은 책임)입니다. – Mehran
죄송합니다. 다른 질문에 대해 잊어 버렸습니다. 나는 오히려 포스트 픽스에만 집중할 것이다. – Mehran