문제

Prestashop을 전자 상거래 쇼핑 카트 및 CMS 솔루션으로 사용하고 있으며 연락처 양식을 통해 전송 된 이메일을받는 데 문제가있었습니다. 나는 주위에 '주소에서'주소를 내 도메인에서 할당해야한다는 사실로 인한 문제를 발견하고 (예 : do_not_reply@mydomain.com), 사용자가 입력 한 이메일에 다른 변수 (예 : '답장 메일').

그러나 Prestashop 연락처 양식은 별도의 Contact-Form.php 파일과 아래에 표시하는 별도의 Contact-Form.tpl이있는 PHP Smarty Template 엔진으로 작성됩니다. 먼저 contact-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)를 할당하기 위해이 연락처 양식을 어떻게 조정할 수 있는지 아는 사람이 있습니까? 이 'From'주소가 다른 곳에 저장되어 있다면 누구나 저장 될 수있는 위치 또는 코드에서 참조되는 위치를 볼 수 있습니까?

도움이 되었습니까?

해결책

이 'From'주소가 다른 곳에 저장되어 있다면 누구나 저장 될 수있는 위치 또는 코드에서 참조되는 위치를 볼 수 있습니까?

코드에서 말할 수는 없지만 내 강한 추측은이 파일 일 것입니다.

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

편집하다:

 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'

~할 것 같다 트릭을하십시오.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top