PHPのメール(お問い合わせ-米国オプションの場合は入力するGmailメールの送信アドレスなデジタルマーケティン[複製]

StackOverflow https://stackoverflow.com/questions/2133442

質問

この問いは正確な複製のもの

私の設定は、ecサイトを利用Prestashopときを、お問い合わせフォームを実感したのを受けていないメッセージがユーザーがヤフーとして電子メールアドレスと発信者アドレスです。ほどの場所に位置していをした場合で、ユーザ、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 !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');

?> 

更新:
に連絡して私のメールホスティング会社にて、以下の提言-

ご変更が必要なメール アドレス分野にお$からいず メールアドレスのドメイン名 でこれを組み込んだ スクリプト例えば、ドメイン 名abc.comそばの定義 のからのメールアドレスとして ものがたりname@abc.com.このメールアドレス ることを要しない既存のメール サーバーのabc.comただし、ドメイン 名前のかき ます。使用メールアドレス などDo_Not_reply@abc.com.

この値は$mailto分野のニーズ toが存在する場合がありますのでメールアドレス、 場など)のメールアドレスを入力データ フォームを経由して送信されたニーズに ます。

そのPrestashopのcontact-form.php (コードされた)、あなたは何点ぐらいになると思って変化するのですか?

役に立ちましたか?

解決 5

の解決のためにこのが発見されており、それらのこの質問質問質問質問質問とほぼ同じです:- 構築PHPのMail()Smarty問合せフォーム.

他のヒント

PHPのmail()は原送しています。ですが整ったものとのmail()がわからない場合は、メール強化(標準)...

ていただきたいへの利用 PHPMailer (またはそれに類似するものlibrairies)または郵送により実際のコードをご用になります。

使用できませんのアドレスな結合をサーバーとして送信者アドレスといったこのブロックをすることによる毎に自己を尊重し迷惑メールブロック機構。これは実際奇跡でGMailアドレスといった

いることはでき返信メールを人々に送ります。は、お問い合わせフォームに以下のエントリを追加するヘッダの4パラメータを mail() 電話:

reply-to: customers_email_address

しかし、物理送信者アドレス、 常に 使用

from: something@yourserver.com

が目のパラメータを提供することもできるの mail() ます。

ここには何を使ってもシステムを変更メール(簡体字)はこちら:

return @mail($message['to'],
             $message['subject'],
             $message['body'],
             join("\n", $mimeheaders),
             '-f' . $message['from'] );

以来、AlexV正しく述べることをエスケープ解除値るのは危険ですが、これは、フルバージョン。りますのでご注意くださいながら、drupal源(小型の修正)。

    function drupal_mail_wrapper($message)
    {
        $mimeheaders = array();

        foreach ($message['headers'] as $name => $value) 
        {
            $mimeheaders[] = $name .': '. mime_header_encode($value);
        }

        return @mail(
            $message['to'],
            mime_header_encode($message['subject']),
            // Note: e-mail uses CRLF for line-endings, but PHP's API requires LF.
            // They will appear correctly in the actual e-mail that is sent.
            str_replace("\r", '', $message['body']),
            // For headers, PHP's API suggests that we use CRLF normally,
            // but some MTAs incorrecly replace LF with CRLF. See #234403.
            join("\n", $mimeheaders),
            ($message['from'] ? '-f' . $message['from'] : '') );
    }

いーす クリス

ってこの小さなコードの送付eメールニュースレターシステムを自作してました。この抜粋取り扱う具体的には単一のメッセージ。このRFCに基づく仕様


    /**
     * @package  jaMailBroadcast
     * @author   Joel A. Villarreal Bertoldi (design at joelalejandro.com)
     *
     * @usage    
     *
     *     $msg = new jaMailBroadcast_Message("My Website", "my@website.com");
     *     $msg->to = new jaMailBroadcast_Contact("John Doe", "john@doe.com");
     *     $msg->subject = "Something";
     *     $msg->body = "Your message here. You <b>can use</b> HTML.";
     *     $msg->send();
     **/

    class jaMailBroadcast_Contact
    {
        public $id;
        public $name;
        public $email;

        function __construct($contactName, $contactEmail, $contactId = "")
        {
            $this->name = $contactName;
            $this->email = $contactEmail;
            if (!$contactId)
                $this->id = uniqid("contact_");
            else
                $this->id = $contactId;
        }

        function __toString()
        {
            return json_encode
            (
                array
                (
                  "id" => $this->id,
                  "name" => $this->name,
                  "email" => $this->email
                )
            );
        }

        function rfc882_header()
        {
            return sprintf('"%s" ', $this->name, $this->email);
        }
    }

    class jaMailBroadcast_Message
    {
        public $from;
        public $to;
        public $subject;
        public $body;
        public $mime_boundary;
        public $headerTemplate;
        public $footerTemplate;

        function __construct($fromName, $fromEmail)
        {
            $this->from = new jaMailBroadcast_Contact($fromName, $fromEmail);
            $this->mime_boundary = "==" . md5(time());
        }

        private function mail_headers($EOL = "\n")
        {
            $headers
              = "From: " . $this->from->rfc882_header() . $EOL
              . "Reply-To: from->email . ">" . $EOL
              . "Return-Path: from->email . ">" . $EOL
              . "MIME-Version: 1.0" . $EOL
              . "Content-Type: multipart/alternative; boundary=\"{$this->mime_boundary}\"" . $EOL
              . "User-Agent: jaMailBroadcast/1.0" . $EOL
              . "X-Priority: 3 (Normal)" . $EOL
              . "Importance: Normal" . $EOL
              . "X-Mailer: jaMailBroadcast";

            return $headers;
        }

        private function rfc882_body_format($EOL = "\r\n")
        {
          return wordwrap($this->body, 70, $EOL);
        }

        function send()
        {
            $EOL =
                 (
                    stripos($this->to->email, "hotmail") !== false
                  ||
                    stripos($this->to->email, "live") !== false
                 )
                  ? "\n"
                  : "\n";

            return mail
            (
                $this->to->rfc882_header(),
                $this->subject,
                $this->multipart_alternative_body($EOL),
                $this->mail_headers($EOL),
                "-f" . $this->from->email
            );
        }

        private function multipart_alternative_body($EOL = "\r\n")
        {
            $multipart
                    = "Content-Transfer-Encoding: 7bit" . $EOL
                    . "This is a multi-part message in MIME format. This part of the E-mail should never be seen. If you are reading this, consider upgrading your e-mail client to a MIME-compatible client." . $EOL . $EOL
                    = "--{$this->mime_boundary}" . $EOL
                    . "Content-Type: text/plain; charset=iso-8859-1" . $EOL
                    . "Content-Transfer-Encoding: 7bit" . $EOL . $EOL
                    . strip_tags($this->br2nl($this->headerTemplate)) . $EOL . $EOL
                    . strip_tags($this->br2nl($this->body)) . $EOL . $EOL
                    . strip_tags($this->br2nl($this->footerTemplate)) . $EOL . $EOL
                    . "--{$this->mime_boundary}" . $EOL
                    . "Content-Type: text/html; charset=iso-8859-1" . $EOL
                    . "Content-Transfer-Encoding: 7bit" . $EOL . $EOL
                    . $this->headerTemplate . $EOL
                    . $this->body . $EOL
                    . $this->footerTemplate . $EOL
                    . "--{$this->mime_boundary}--" . $EOL;

            return $multipart;
        }

        private function br2nl($text, $EOL = "\n")
        {
            $text = str_ireplace("<br>", $EOL, $text);
            $text = str_ireplace("<br />", $EOL, $text);
            return $text;
        }
    }

いのかを $_REQUEST['from'].に変更することができ $_POST['from'] しています。交換2'から'この変更 $contact->email を任意のメールがきを送ります。

たところ、うまくいったのです。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top