如何自定义联系表单代码以将副本发送到另一封电子邮件?

时间:2016-02-09 09:24:53

标签: php wordpress email

我在wordpress网站上安装了一个主题,我想修改联系人所有者表单的代码。 有人可以帮忙这个代码吗? 每当有人通过此网站/门户网站向供应商发送电子邮件时,我都希望将副本发送到我的电子邮箱。 我可以在何处以及在何处添加代码?

以下是file

的链接



<?php

/*
 * AIT WordPress Theme Framework
 *
 * Copyright (c) 2013, Affinity Information Technology, s.r.o. (http://ait-themes.com)
 */


class AitContactOwnerAjax extends AitFrontendAjax
{

	/**
	 * @WpAjax
	 */
	public function send()
	{
		$matches = array();
		preg_match_all('/{([^}]*)}/', $_POST['response-email-content'], $matches);

		foreach($matches[1] as $i => $match){
			$_POST['response-email-content'] = str_replace($matches[0][$i], $_POST[$match], $_POST['response-email-content']);
		}

		$_POST['response-email-content'] = str_ireplace(array("\r\n", "\n"), "<br />", $_POST['response-email-content']);

		$senderName = isset($_POST['response-email-sender-name']) ? $_POST['response-email-sender-name'] : '';

		$headers = array(
			'Content-Type: text/html; charset=UTF-8',
			'Reply-To: '.$_POST['user-name'].' <'.$_POST['user-email'].'>',
			'From: '.$senderName.' <'.$_POST['response-email-sender-address'].'>', 
		);
		//$headers = 'From: '.$_POST['user-name'].' <'.$_POST['user-email'].'>' . "\r\n";
		wp_mail($_POST['response-email-address'], $_POST['response-email-subject'], $_POST['response-email-content'], $headers, null);
		$this->sendJson(array('message' => sprintf(__("Mail sent to %s", 'ait'), $_POST['response-email-address'])));
	}
}
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

试试这个:

$headers = array(
        'Content-Type: text/html; charset=UTF-8',
        'Reply-To: '.$_POST['user-name'].' <'.$_POST['user-email'].'>',
        'From: '.$senderName.' <'.$_POST['response-email-sender-address'].'>', 
        'CC: '.$yourname.' <'.$youremail.'>', 
    );