1

Web サイトから hotmail アカウントに簡単なメール スクリプトを送信しようとしていますが、スパム (cgi メーラー) として表示され続けます。from 部分のヘッダーと関係があることは知っていますが、すべてを機能させる方法を理解できないようです..これが私が得たものです...

<?php 
$name =  $_POST['contact_name'] ;
$email = $_POST['contact_email'] ;
$from= "$name <$email>;"
$company = $_POST['contact_company'] ;
$number = $_POST['contact_phone'] ;

// $message = $_POST['contact_message'], "Name:" . $name,"Telephone Number:" .        $number;
$message = $_POST['contact_message'];
$message .= "Name:" . $name;
$message .= "Telephone Number:" . $number;
$to = "bcplumbing-heating@hotmail.co.uk";
$subject = "ContactForm";
$headers = "From:" . $from;

//modify the mail function
mail($to,$subject,$message,$headers);
?>

どんな助けやアドバイスも素晴らしいでしょう...ありがとう

4

4 に答える 4

1

Hotmail は、いくつかの複雑なスパム チェックを行います。これは、RBL リストと逆引きを超えています。

  • たとえば、 test@test.deからメールを送信する場合。次に、hotmail は、送信メールサーバーからの IP がドメインtest.deに戻るかどうかを確認します(逆引き)。

  • 次のポイントは、電子メール サーバーの構成が正しいことです。

おそらく、アプリケーション サイトのより良い方法は、自動的に作成されるメール システムを使用することです。

私はここSwitftmailerを好みます。

于 2013-06-07T13:03:27.483 に答える
0

gmail などのメール サーバーから SMTP を使用してメールを送信すると、迷惑メール フォルダーに届かないようにすることができます。次のスクリプトを使用できます。

メールページ:

<?php
require "email.php";

$mail = new EMail;
$mail->Username = 'somthing@mydomain.co.uk';
$mail->Password = 'thepassword';

$mail->SetFrom("some@address.com","Some name");  // Name is optional
$mail->AddTo("someother@address.com","Someother name"); // Name is optional
$mail->AddTo("someother2@address.com");
$mail->Subject = "Some subject or other";
$mail->Message = "Some html message";

//Optional stuff
$mail->AddCc("someother3@address.com","name 3");  // Set a CC if needed, name optional
$mail->ContentType = "text/html";          // Defaults to "text/plain; charset=iso-8859-1"
$mail->Headers['X-SomeHeader'] = 'abcde';  // Set some extra headers if required
$mail->ConnectTimeout = 30;  // Socket connect timeout (sec)
$mail->ResponseTimeout = 8;  // CMD response timeout (sec)

$success = $mail->Send();

?>

email.php:

<?php

//email.php: Sends an email using an auth smtp connection
//v3

class EMail
{
  const newline = "\r\n";

  private
    $Server, $Port, $Localhost,
    $skt;

  public
    $Username, $Password, $ConnectTimeout, $ResponseTimeout,
    $Headers, $ContentType, $From, $To, $Cc, $Subject, $Message,
    $Log;

  function __construct()
  {
    $this->Server = "127.0.0.1";
    $this->Port = 25;
    $this->Localhost = "localhost";
    $this->ConnectTimeout = 30;
    $this->ResponseTimeout = 8;
    $this->From = array();
    $this->To = array();
    $this->Cc = array();
    $this->Log = array();
    $this->Headers['MIME-Version'] = "1.0";
    $this->Headers['Content-type'] = "text/plain; charset=iso-8859-1";
  }

  private function GetResponse()
  {
    stream_set_timeout($this->skt, $this->ResponseTimeout);
    $response = '';
    while (($line = fgets($this->skt, 515)) != false)
    {
 $response .= trim($line) . "\n";
 if (substr($line,3,1)==' ') break;
    }
    return trim($response);
  }

  private function SendCMD($CMD)
  {
    fputs($this->skt, $CMD . self::newline);

    return $this->GetResponse();
  }

  private function FmtAddr(&$addr)
  {
    if ($addr[1] == "") return $addr[0]; else return "\"{$addr[1]}\" <{$addr[0]}>";
  }

  private function FmtAddrList(&$addrs)
  {
    $list = "";
    foreach ($addrs as $addr)
    {
      if ($list) $list .= ", ".self::newline."\t";
      $list .= $this->FmtAddr($addr);
    }
    return $list;
  }

  function AddTo($addr,$name = "")
  {
    $this->To[] = array($addr,$name);
  }

  function AddCc($addr,$name = "")
  {
    $this->Cc[] = array($addr,$name);
  }

  function SetFrom($addr,$name = "")
  {
    $this->From = array($addr,$name);
  }

  function Send()
  {
    $newLine = self::newline;

    //Connect to the host on the specified port
    $this->skt = fsockopen($this->Server, $this->Port, $errno, $errstr, $this->ConnectTimeout);

    if (empty($this->skt))
      return false;

    $this->Log['connection'] = $this->GetResponse();

    //Say Hello to SMTP
    $this->Log['helo']     = $this->SendCMD("EHLO {$this->Localhost}");

    //Request Auth Login
    $this->Log['auth']     = $this->SendCMD("AUTH LOGIN");
    $this->Log['username'] = $this->SendCMD(base64_encode($this->Username));
    $this->Log['password'] = $this->SendCMD(base64_encode($this->Password));

    //Email From
    $this->Log['mailfrom'] = $this->SendCMD("MAIL FROM:<{$this->From[0]}>");

    //Email To
    $i = 1;
    foreach (array_merge($this->To,$this->Cc) as $addr)
      $this->Log['rcptto'.$i++] = $this->SendCMD("RCPT TO:<{$addr[0]}>");

    //The Email
    $this->Log['data1'] = $this->SendCMD("DATA");

    //Construct Headers
    if (!empty($this->ContentType))
      $this->Headers['Content-type'] = $this->ContentType;
    $this->Headers['From'] = $this->FmtAddr($this->From);
    $this->Headers['To'] = $this->FmtAddrList($this->To);
    if (!empty($this->Cc))
      $this->Headers['Cc'] = $this->FmtAddrList($this->Cc);
    $this->Headers['Subject'] = $this->Subject;
    $this->Headers['Date'] = date('r');

    $headers = '';
    foreach ($this->Headers as $key => $val)
      $headers .= $key . ': ' . $val . self::newline;

    $this->Log['data2'] = $this->SendCMD("{$headers}{$newLine}{$this->Message}{$newLine}.");

    // Say Bye to SMTP
    $this->Log['quit']  = $this->SendCMD("QUIT");

    fclose($this->skt);

    return substr($this->Log['data2'],0,3) == "250";
  }
}
?>
于 2013-06-07T13:12:00.660 に答える