cPanel – 拥有独一无二的转发地址

我正在尝试configuration一个邮件[email protected]并对其进行configuration,以便[email protected]发送邮件给[email protected]时,它会发送到sarah @ jane @和tom @(对不起蹩脚的例子!)

这个邮件必须通过FROM from [email protected]到达所有的“列表” 这样他们才可以在那里回复,其他人都可以得到它。

没有主要的“批量电子邮件”提供商(phplist等)似乎可以这样configuration。

我很乐意提供build议,希望我自己解释一下,如果不是的话,请澄清!

编辑:

我同意Kyle Brants的评论,这可以通过邮件列表(在cPanel中)MAILMAN完成,但是我仍然不知道如何configuration它!

谢谢!

你需要安装一个邮件列表程序,例如使用cPanel的phpList。

去Fantastico De Luxe,selectphpList。

这里是HostGator的指示: http : //support.hostgator.com/articles/e-mail/how-to-set-up-a-mailing-list-in-cpanel 。

这SiteGround cPanel电子邮件转发教程应该解释一切你需要设置一个转发器。

10/20编辑:编写一个bash脚本来完成这个任务似乎是很有趣的(起初,无论如何),但是在formail缺lessMIME multipart支持使得它变得丑陋。

我可能会在稍后的日子尝试一下PHP脚本,但是使用预先打包的解决scheme的build议比试图推出自己的更有意义。

10/21编辑:我把这个作为一种挑战,所以在这里(没有任何支持/工作代码的保证)是我想出了 – 我仍然build议使用现有的解决scheme使用这个脚本,但我不能抵制脚本的概念certificate。

我得到它与cPanel安装工作,但我没有打扰w / MIME的支持,所以附件和HTML电子邮件将被剥离,只有明文将被交付。

  1. 将脚本(如下)保存到一个文件并更新以匹配您的cPanelconfiguration
  2. 上传文件到/home/example/mail-everyone.php (或类似),然后按照pipe道到脚本的设置指南(Address to Forward:“everyone”,Pipe to program:“mail-everyone.php”)
  3. 发送一些testing消息 – 您应该看到消息打到您的NOTIFY_EMAIL帐户用debugging电子邮件(直到FLAG_DEBUG设置为false),所有其他启用cPanel的电子邮件地址应该看到明文密件抄送副本。

 <?php define( 'FLAG_DEBUG', true ); // default: true define( 'FLAG_DEBUG_RAW', false ); // default: false define( 'NOTIFY_EMAIL', '[email protected]' ); define( 'CPANEL_DOMAIN', 'example.com' ); define( 'CPANEL_PATH', '/home/example/' ); define( 'CPANEL_PATH_USERS', constant('CPANEL_PATH') . 'etc/' . constant('CPANEL_DOMAIN') . '/quota' ); define( 'EML_SENDER', 'everyone@' . constant('CPANEL_DOMAIN') ); define( 'EML_SUBJECT_PREPEND', '(everyone) ' ); define( 'EML_SUBJECT_APPEND', '' ); define( 'EML_XMAILER', __FILE__.'; PHP/'.phpversion() ); define( 'END_LINE', "\r\n" ); function debugging( $message, $notify = false ) { global $debugging; if ( defined('FLAG_DEBUG') && constant('FLAG_DEBUG') ) { $debugging[] = $message; } if ( $notify ) { $outgoing_headers = array( 'From' => constant('EML_SENDER'), 'Reply-To' => constant('NOTIFY_EMAIL'), 'X-Mailer' => constant('EML_XMAILER') ); $message = implode( constant('END_LINE'), $debugging ); $flag_sent = send_mail( constant('NOTIFY_EMAIL'), __FILE__.': Debug Notice', $message, $outgoing_headers ); } return; } function scan_headers( $search, $target ) { $matches = array(); $pattern = '/^' . strtolower($target) . ':/i'; if ( preg_match( $pattern, $search ) ) { return substr( $search, strlen($target . ': ') ); } } function send_mail( $to, $subject, $message, $headers_array = false ) { if ( is_array($headers_array) ) { $header_string = ''; foreach ( $headers_array as $key => $value ) { $header_string .= $key.': '.$value . constant('END_LINE'); } } return ( @mail( $to, $subject, $message, $header_string ) ); } if ( !defined('CPANEL_DOMAIN') || !defined('CPANEL_PATH') || !defined('CPANEL_PATH_USERS') || !defined('EML_SENDER') || !defined('EML_XMAILER') || !defined('FLAG_DEBUG') || !defined('FLAG_DEBUG_RAW') || !defined('NOTIFY_EMAIL') || !defined('END_LINE') || constant('NOTIFY_EMAIL') == constant('EML_SENDER') ) { exit(1); } $debugging = array(); $flag_headers = 1; $flag_plaintext = 1; $flag_multi_plaintext = 0; $flag_multi_plaintext_done = 0; $headers_incoming = array( 'To' => '', 'From' => '', 'Reply-To' => '', 'Subject' => '', 'Cc' => '' ); $mime_boundary = ''; $plaintext = ''; debugging('searching for users'); $users = array(); $quota_users = @file( constant('CPANEL_PATH_USERS') ); if ( $quota_users && is_array($quota_users) && count($quota_users) ) { foreach ( $quota_users as $quota_user ) { $user = strtok($quota_user,':') . '@' . constant('CPANEL_DOMAIN'); debugging('searching for users: +user "'.$user.'"'); $users[] = $user; } } else { debugging('searching for users: ERROR - check CPANEL_PATH_USERS "'.constant('CPANEL_PATH_USERS').'"', true); exit(1); } debugging('searching for users done: ' . count($users) . ' users'); debugging('header processing begins'); $line_count = 0; $line_last = ''; while( $line = fgets(STDIN) ) { if ( $line_count >= 5000 ) break; $line = trim($line); if ( $flag_headers ) { foreach ( $headers_incoming as $target => $set ) { if ( !$set ) { $found = scan_headers( $line, $target ); if ( $found ) { $headers_incoming[$target] = $found; debugging('headers: set '.$target.': "'.$found.'"'); } } } if ( strpos($line, 'boundary=') ) { $flag_plaintext = false; debugging('headers: multipart message detected'); } if ( strlen($line) <= 3 ) { $flag_headers = false; debugging('header processing ends'); } } else if ( $flag_plaintext ) { // (default) plain text message // everything after headers will be relayed debugging('plaintext: +line "'.$line.'"'); $plaintext .= $line . constant('END_LINE'); } else if ( $flag_multi_plaintext ) { if ( preg_match( '/^' . $mime_boundary . '/', $line ) ) { debugging('multipart/text: reached boundary "'.$mime_boundary.'"'); $flag_multi_plaintext = false; $flag_multi_plaintext_done = true; } else { debugging('multipart/text: +line "'.$line.'"'); $plaintext .= $line . constant('END_LINE'); } } else if ( !$flag_multi_plaintext_done ) { if ( preg_match( '/^Content-Type: text\/plain/', $line ) ) { $mime_boundary = $line_last; debugging('multipart/text: matched "Content-Type: text/plain" header'); $flag_multi_plaintext = true; } } if ( constant('FLAG_DEBUG_RAW') ) debugging( 'raw message: +line "' . $line . '"' ); $line_last = $line; $line_count++; } if ( $headers_incoming['To'] != constant('EML_SENDER') || $headers_incoming['From'] == constant('EML_SENDER') ) { debugging( 'skipped resending to avoid loop - To: "'.$headers_incoming['To'].'" / From: "'.$headers_incoming['From'].'"', constant('FLAG_DEBUG') ); exit(0); } debugging('resending begins'); if ( strlen($plaintext) ) { $reply_recipient = ($headers_incoming['Reply-To']) ? $headers_incoming['Reply-To'] : $headers_incoming['From']; $subject = $headers_incoming['Subject']; $subject = (defined('EML_SUBJECT_PREPEND')) ? constant('EML_SUBJECT_PREPEND') . $subject : $subject; $subject = (defined('EML_SUBJECT_APPEND')) ? $subject . constant('EML_SUBJECT_APPEND') : $subject; $users_bcc = ''; foreach ( $users as $user_email ) { debugging('resending: +email bcc: "'.$user_email.'"'); $users_bcc .= ($users_bcc) ? ',' . $user_email : $user_email; } $outgoing_headers = array( 'From' => constant('EML_SENDER'), 'Cc' => constant('EML_SENDER'), 'Bcc' => $users_bcc, 'Reply-To' => $reply_recipient, 'X-Mailer' => constant('EML_XMAILER') ); if ( send_mail( constant('NOTIFY_EMAIL'), $subject, $plaintext, $outgoing_headers ) ) { debugging( 'resending ends - success', constant('FLAG_DEBUG') ); } else { debugging('resending: failed sending to "'.$users_bcc.'"', constant('FLAG_DEBUG') ); exit(1); } } else { debugging( 'error: nothing to relay', true ); exit(1); } exit(0); ?>