重新配置PHP Mail()Smarty联系人表单

重新配置PHP Mail()Smarty联系人表单,php,forms,smarty,template-engine,prestashop,Php,Forms,Smarty,Template Engine,Prestashop,我使用Prestashop作为我的电子商务购物车和CMS解决方案,在接收通过联系人表单发送的电子邮件时遇到问题。我四处询问,发现问题是因为我需要将“发件人”地址指定为我域中的某个内容,例如“请勿”_reply@mydomain.com用户输入的电子邮件将被分配一个不同的变量,例如“replyemail” 但是,Prestashop联系人表单是使用一个PHP Smarty模板引擎创建的,它有单独的contact-form.PHP文件和一个单独的contact-form.tpl,我将在下面展示。 首

我使用Prestashop作为我的电子商务购物车和CMS解决方案,在接收通过联系人表单发送的电子邮件时遇到问题。我四处询问,发现问题是因为我需要将“发件人”地址指定为我域中的某个内容,例如“请勿”_reply@mydomain.com用户输入的电子邮件将被分配一个不同的变量,例如“replyemail”

但是,Prestashop联系人表单是使用一个PHP Smarty模板引擎创建的,它有单独的contact-form.PHP文件和一个单独的contact-form.tpl,我将在下面展示。 首先联系-form.php:-

<?php

$useSSL = true;

include(dirname(__FILE__).'/config/config.inc.php');
include(dirname(__FILE__).'/header.php');

$errors = array();

$smarty->assign('contacts', Contact::getContacts(intval($cookie->id_lang)));

if (Tools::isSubmit('submitMessage'))
{
    if (!($from = Tools::getValue('from')) OR !Validate::isEmail($from))
        $errors[] = Tools::displayError('invalid e-mail address');
    elseif (!($message = nl2br2(Tools::getValue('message'))))
        $errors[] = Tools::displayError('message cannot be blank');
    elseif (!Validate::isMessage($message))
        $errors[] = Tools::displayError('invalid message');
    elseif (!($id_contact = intval(Tools::getValue('id_contact'))) OR !(Validate::isLoadedObject($contact = new Contact(intval($id_contact), intval($cookie->id_lang)))))
        $errors[] = Tools::displayError('please select a contact in the list');
    else
    {
        if (intval($cookie->id_customer))
            $customer = new Customer(intval($cookie->id_customer));
        if (Mail::Send(intval($cookie->id_lang), 'contact', 'Message from contact form', array('{email}' => $_POST['from'], '{message}' => stripslashes($message)), $contact->email, $contact->name, $from, (intval($cookie->id_customer) ? $customer->firstname.' '.$customer->lastname : $from)))
            $smarty->assign('confirmation', 1);
        else
            $errors[] = Tools::displayError('an error occurred while sending message');
    }
}

$email = Tools::safeOutput(Tools::getValue('from', ((isset($cookie) AND isset($cookie->email) AND Validate::isEmail($cookie->email)) ? $cookie->email : '')));
$smarty->assign(array(
    'errors' => $errors,
    'email' => $email
));

$smarty->display(_PS_THEME_DIR_.'contact-form.tpl');
include(dirname(__FILE__).'/footer.php');

?>
接下来是contact-form.tpl文件的代码:-

{capture name=path}{l s='Contact'}{/capture}

{include file=$tpl_dir./breadcrumb.tpl}



<h2>{l s='Contact us'}</h2>



{if isset($confirmation)}

    <p>{l s='Your message has been successfully sent to our team.'}</p>

    <ul class="footer_links">

        <li><a href="{$base_dir}"><img class="icon" alt="" src="{$img_dir}icon/home.gif"/></a><a href="{$base_dir}">{l s='Home'}</a></li>

    </ul>

{else}

    <p class="bold">{l s='For questions about an order or for information about our products'}.</p>

    {include file=$tpl_dir./errors.tpl}

    <form action="{$request_uri|escape:'htmlall':'UTF-8'}" method="post" class="std">

        <fieldset>

            <h3>{l s='Send a message'}</h3>

            <p class="select">

                <label for="id_contact">{l s='Subject'}</label>

                <select id="id_contact" name="id_contact" onchange="showElemFromSelect('id_contact', 'desc_contact')">

                    <option value="0">{l s='-- Choose --'}</option>

                {foreach from=$contacts item=contact}

                    <option value="{$contact.id_contact|intval}" {if isset($smarty.post.id_contact) && $smarty.post.id_contact == $contact.id_contact}selected="selected"{/if}>{$contact.name|escape:'htmlall':'UTF-8'}</option>

                {/foreach}

                </select>

            </p>

            <p id="desc_contact0" class="desc_contact">&nbsp;</p>

        {foreach from=$contacts item=contact}

            <p id="desc_contact{$contact.id_contact|intval}" class="desc_contact" style="display:none;">

            <label>&nbsp;</label>{$contact.description|escape:'htmlall':'UTF-8'}</p>

        {/foreach}

        <p class="text">

            <label for="email">{l s='E-mail address'}</label>

            <input type="text" id="email" name="from" value="{$email}" />

        </p>

        <p class="textarea">

            <label for="message">{l s='Message'}</label>

             <textarea id="message" name="message" rows="7" cols="35">{if isset($smarty.post.message)}{$smarty.post.message|escape:'htmlall':'UTF-8'|stripslashes}{/if}</textarea>

        </p>

        <p class="submit">

            <input type="submit" name="submitMessage" id="submitMessage" value="{l s='Send'}" class="button_large" />

        </p>

    </fieldset>

</form>

{/if}
是否有人知道我如何调整此联系表以分配我选择的发件人地址,例如do_not_reply@mydomain.com希望这封邮件能开始为我工作。如果这个“发件人”地址存储在其他地方,有人能看到它可能存储在哪里或者它在代码中引用的位置吗

如果这个“发件人”地址存储在其他地方,有人能看到它可能存储在哪里或者它在代码中引用的位置吗

我无法从代码中分辨出来,但我的猜测是这个文件:

include(dirname(__FILE__).'/config/config.inc.php');
编辑:

我现在无法仔细查看代码,但替换了其中任何一个


也许能奏效

当前的“发件人”地址实际上不是dou not的形式_reply@mydomain.com. 我认为它是根据用户在提交表单之前输入电子邮件地址时输入的数据自动生成的。但是我会看一看config.inc.php,看看里面有什么。重点是我希望“from”地址是我事先指定的,例如do_not_reply@mydomain.com我希望用户输入的地址是我将在他们发送的电子邮件中收到的“回复地址”。是的,当我将$from更改为'donotreply@mydomain.com'. 有两个$from的实例,我需要更改这两个实例以使其工作。谢谢
 if (Mail::Send(intval($cookie->id_lang), 'contact', 'Message from contact form', 
array('{email}' => $_POST['from'], '{message}' => stripslashes($message)), 
$contact->email, $contact->name, $from, (intval($cookie->id_customer) ? 
$customer->firstname.' '.$customer->lastname : $from)))
'{email}' => $_POST['from']
$from
'{email}' => 'whatever_you_want'
'whatever_you_want'