<?php

$contents = file_get_contents("php://stdin");

preg_match_all("/[^[:space:]<@]+(?:@[^[:space:]>]+)+/", $contents, $matches);
print_r($matches);
preg_match_all("/\b([a-z0-9%\._\+\-]+@[a-z0-9-\.]+\.[a-z]{2,6})\b/Ui", $contents, $matches);
print_r($matches);