До того, как я использовал функцию почты в PHP в моей контактной форме.
Однако моя хостинговая компания теперь занесена в черный список, что является настоящей болью.
Итак, теперь цель в том, чтобы использовать SMTP.
Приведенный ниже код работает, но отбрасывает все на спам.
Пожалуйста, не дайте мне негатива за вопрос.Я проверил на Google и прочитал другие источники.Я ищу помощь.
//STARTING HERE
require_once 'lib/swift_required.php';
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, "ssl")
->setUsername('example@gmail.com')
->setPassword('example')
;
$transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');
$transport = Swift_MailTransport::newInstance();
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance('Wonderful Subject')
->setFrom(array('contact@example.example' => 'Contact form'))
->setTo(array('123@gmail.com', '123@123.com' => 'Author leon'))
->setBody('Here is the message itself')
;
$result = $mailer->send($message);
if ($result)
echo "Success " . $result; // if 1 one email has been sent, if 2 then two emails hes been sent.
else
echo "Error";
?>
EMAIL HEADER
Delivered-To: example@example.com
Received: by 10.204.231.11 with SMTP id jo11cs300466bkb;
Wed, 1 Feb 2012 08:11:30 -0800 (PST)
Received: by 10.180.77.228 with SMTP id v4mr19801267wiw.2.1328112690201;
Wed, 01 Feb 2012 08:11:30 -0800 (PST)
Return-Path: <contact@example.example.tv>
Received: from rweb2-v.000025.net (rweb2-v.000025.net. [89.238.128.229])
by mx.google.com with ESMTPS id u2si18187663weq.118.2012.02.01.08.11.29
(version=TLSv1/SSLv3 cipher=OTHER);
Wed, 01 Feb 2012 08:11:29 -0800 (PST)
Received-SPF: neutral (google.com: 89.238.128.229 is neither permitted nor denied by best guess record for domain of contact@example.example.tv) client-ip=89.238.128.229;
Authentication-Results: mx.google.com; spf=neutral (google.com: 89.238.128.229 is neither permitted nor denied by best guess record for domain of example@example.tv) smtp.mail= example@example.tv
Received: from pib by rweb2-v.000025.net with local (Exim 4.69)
(envelope-from <example@example.tv>)
id 1RscmP-000iR1-1g; Wed, 01 Feb 2012 16:11:29 +0000
To: example@example, Author leon <example@example.com>
Subject: Wonderful Subject
Message-ID: <1328112689.4f296431088d2@example.tv>
Date: Wed, 01 Feb 2012 16:11:29 +0000
From: Contact form < example@example.tv>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - rweb2-v.000025.net
X-AntiAbuse: Original Domain - example.com
X-AntiAbuse: Originator/Caller UID/GID - [1144 1145] / [47 12]
X-AntiAbuse: Sender Address Domain – example@example.tv
Here is the message itself