php [pip email forwarders]管道电子邮件到PHP和解析内容,用于cpanel #hosting_domain

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php [pip email forwarders]管道电子邮件到PHP和解析内容,用于cpanel #hosting_domain相关的知识,希望对你有一定的参考价值。

#!/usr/local/php70/bin/php-cli -q
<?php
/*
	* Ensure the very first line of the script is a hashbang (also called shebang)
	* –q option instructs PHP not to print its version either, since this will also result in a bounced message.
*/
$fd = fopen("php://stdin", "r");
$message = "";
while (!feof($fd)) {
$message .= fread($fd, 1024);
}
fclose($fd); 

//split the string into array of strings, each of the string represents a single line, received
$lines = explode("\n", $message);

// initialize variable which will assigned later on
$from = emailFrom@example.com;
$subject = "";
$headers = "";
$message = "";
$is_header= true;

//loop through each line
for ($i=0; $i < count($lines); $i++) {
	if ($is_header) {
		// hear information. instead of main message body, all other information are here.
		$headers .= $lines[$i]."\n";
	 
		// Split out the subject portion
		if (preg_match("/^Subject: (.*)/", $lines[$i], $matches)) {
			$subject = $matches[1];
		}
		//Split out the sender information portion
		if (preg_match("/^From: (.*)/", $lines[$i], $matches)) {
			$from = $matches[1];
		}
	} else {
		// content/main message body information
		$message .= $lines[$i]."\n";
	}
	if (trim($lines[$i])=="") {
		// empty line, header section has ended
		$is_header = false;
	}
}

mail( "emailTo@example.com", $subject,$message, $from );
//http://codesamplez.com/programming/email-to-php-script
?>

以上是关于php [pip email forwarders]管道电子邮件到PHP和解析内容,用于cpanel #hosting_domain的主要内容,如果未能解决你的问题,请参考以下文章

使用 pip 安装 email_validator

启动ip转法功能

Python安装不了email,更新录取pip和setuptools也不行

docker WARNING: IPv4 forwarding is disabled 问题解决

docker IPv4 forwarding is disabled. 解决方法

如何为shell安装有道及更新pip.