PHP Mail()如果输入Gmail发送地址,而不是Yahoo,Contact-us表单正常工作 [英] PHP Mail() Contact-us form works fine if entering a Gmail sending address, but not with Yahoo

查看:196
本文介绍了PHP Mail()如果输入Gmail发送地址,而不是Yahoo,Contact-us表单正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Prestashop设置了一个电子商务网站,当测试他们的联系表单时,我发现如果用户输入Yahoo电子邮件地址作为发件人地址,我没有收到任何消息。但是,如果用户输入Gmail地址,我没有问题。



Prestashop目前设置为使用联系表单的PHP Mail()函数。什么可能是问题,我可以看看什么解决方案,因为我显然需要收到所有人的邮件,而不仅仅是那些与gmail地址。



以下是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!验证: :isEmail($ from))
$ errors [] = Tools :: displayError('invalid e-mail address');
elseif(!($ message = nl2br2(Tools :: getValue('message'))))
$ errors [] = Tools :: displayError('message not not be'
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('请在列表中选择一个联系人);
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('发送消息时发生错误');
$
$ email =工具:: safeOutput(Tools :: getValue('from',((isset($ cookie)AND isset($ cookie->电子邮件)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');

?>






更新: br>
我联系了我的电子邮件托管公司,他们提出以下建议: -


您需要更改电子邮件
字段中的$地址$从

上的域名上的电子邮件地址,您正在合并此
脚本。例如,如果您的域
名称是abc.com,那么您将定义
从电子邮件地址为
some-name@abc.com。此电子邮件地址
不需要存在于abc.com的邮件
服务器上,但是,$ from域中的域
名称必须为
。您可以使用电子邮件地址
,例如Do_Not_reply@abc.com。



$ mailto字段中的值需要
才能更改为电子邮件地址
其中包含通过表单提交的数据
的电子邮件地址需要


所以在Prestashop的contact-form.php(上面给出的代码)的上下文中,我将如何改变它?

解决方案

p>已经找到了解决方案,因为这个问题几乎与以下相同: - 重新配置PHP Mail()Smarty联系表单


I've setup an ecommerce site using Prestashop and when testing their contact form, I found that I was not receiving any messages if user enters Yahoo email address as the senders address. I have no problems, however, if the user enters a Gmail address.

Prestashop is set up currently to use the PHP Mail() function for the contact form. What could be the problem and what solutions could I look at as I obviously need to receive mails from everyone, not just those with gmail addresses.

The following is the code in the contact-form.php page:-

<?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');

?> 


UPDATE:
I contacted my email hosting company and they gave the following suggestion:-

You would need to change the Email address in the field $from to any Email address on the domain name on which you are incorporating this script. For example, if your Domain Name is abc.com, then you would define the From Email address as some-name@abc.com. This Email address need not be existing on the Mail Server of abc.com, however, the domain name in the $from field has to be yours. You may use an Email address such as Do_Not_reply@abc.com.

The value in the $mailto field needs to be changed to the Email address, where email containing the data submitted through the form needs to be delivered.

So in the context of Prestashop's contact-form.php (code given above), how would I go about changing it?

解决方案

The solution for this has been found as this questions is almost identical to:- Reconfiguring PHP Mail() Smarty Contact Form.

这篇关于PHP Mail()如果输入Gmail发送地址,而不是Yahoo,Contact-us表单正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆