【发布时间】:2017-02-03 11:29:32
【问题描述】:
情况:
使用 PHPMailer 在 php 中编写一个函数,用于为网站发送帐户激活邮件。
问题:
我所有的邮件都直接进入垃圾邮件文件夹而不是收件箱。只有 gmail 地址才能正确接收我的邮件。
我的代码:
<?php
/********************************************************************************************************************************
File: sendmail.php
Author: Burtscher Florian
Date: 02.02.2017
Description:
This file contains the sendmail functions for mailing noreply messages to EmailClients.
***************************************************************************************************************************/
require 'PHPMailer-master/PHPMailerAutoload.php';
$result = sendmail('asdf','asdf','asdf','asdf');
if(!$result){
echo $result;
}
function sendmail($to,$subject,$message,$name){
$mail = new PHPMailer;
//$mail->SMTPDebug = 3;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.world4you.com'; //'smtp1.example.com;smtp2.example.com'; // Specifay main and backup SMTP server
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'activation@scritex.com';
$mail->Password = '*************';
$mail->SMTPSecure = 'tls';
$mail->Port = 587; // TCP port to connect
$mail->setFrom('activation@scritex.com', 'Activation');
$mail->addAddress('mytestmail1111@dkimvalidator.com', 'Florian Burtscher'); // Add a recipient
$mail->addReplyTo('activation@scritex.com', 'Office'); // Add Reply To
$mail->isHTML(true);
$mail->Subject = 'Here is a Subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->DKIM_domain = 'scritex.com';
$mail->DKIM_private = '.htkeyprivate';
$mail->DKIM_selector = 'dkim11';
$mail->DKIM_passphrase = '1486107933';
if(!$mail->send()){
return $mail->ErrorInfo;
}else{
return true;
}
}
?>
结果:
我不知道该怎么做。 有谁知道这个问题吗?
我所有的邮件都通过 hotmail、outlook、yahoo、gmx、aon、msn 发送到 spam!
【问题讨论】:
-
mail-tester.com 可以为您提供线索。
标签: php email phpmailer spf dkim