【问题标题】:postmap: warning: database /etc/postfix/sasl_passwd.db is older than source file /etc/postfix/sasl_passwdpostmap:警告:数据库 /etc/postfix/sasl_passwd.db 比源文件 /etc/postfix/sasl_passwd 旧
【发布时间】:2021-02-18 21:15:19
【问题描述】:

我正在服务器 ubuntu 18.04 上的 amazon aws ec2 上工作...我正在尝试使用 phpmailer 发送邮件..当我点击发送邮件时,它显示我发送邮件的消息...但我没有收到任何邮件。当我去 mail.log 文件检查它显示的错误时..它显示以下错误

postfix/smtp[32208]: warning: database /etc/postfix/sasl_passwd.db is older than source file /etc/postfix/sasl_passwd
Nov  6 05:33:52 ip-172-31-16-223 postfix/smtp[32208]: ECD64BE5CC: to=<archipatel20@gmail.com>, relay=mail.uway.in[166.62.28.116]:587, delay=1.9, delays=0.01/0.02/1.6/0.23, dsn=5.0.0, status=bounced (host mail.uway.in[166.62.28.116] said: 550 SMTP AUTH is required for message submission on port 587 (in reply to RCPT TO command))
Nov  6 05:33:52 ip-172-31-16-223 postfix/cleanup[32206]: C81D4BE60F: message-id=<20201106053352.C81D4BE60F@ip-172-31-16-223.us-east-2.compute.internal>
Nov  6 05:33:52 ip-172-31-16-223 postfix/qmgr[32200]: C81D4BE60F: from=<>, size=2669, nrcpt=1 (queue active)
Nov  6 05:33:52 ip-172-31-16-223 postfix/bounce[32210]: ECD64BE5CC: sender non-delivery notification: C81D4BE60F
Nov  6 05:33:52 ip-172-31-16-223 postfix/qmgr[32200]: ECD64BE5CC: removed
Nov  6 05:33:54 ip-172-31-16-223 postfix/smtp[32208]: C81D4BE60F: to=<crm@uway.in>, relay=mail.uway.in[166.62.28.116]:587, delay=1.8, delays=0/0/1.6/0.22, dsn=5.0.0, status=bounced (host mail.uway.in[166.62.28.116] said: 550 SMTP AUTH is required for message submission on port 587 (in reply to RCPT TO command))
Nov  6 05:33:54 ip-172-31-16-223 postfix/qmgr[32200]: C81D4BE60F: removed

这也是我发送邮件的 php 代码:

<?php 

$output = 'here is my html code';

if(isset($_POST["action"]))
{
include('../conn.php');

$getid = $_GET['id'];

$queryd = "SELECT * FROM `salary_sleep_gen` WHERE `id`='$getid'";

$rund = mysqli_query($conn, $queryd);

while ($rowd = mysqli_fetch_array($rund)) {
    $emaild = $rowd['email'];
    $monthbname = $rowd['month_name'];
    $yearb = $rowd['year'];
    $emp_nameb = $rowd['emp_name'];
}
include('pdf.php');
    $file_name = md5(rand()) . '.pdf';
    $html_code = '<link rel="stylesheet" href="bootstrap.min.css">';
    $html_code .= fetch_customer_data($connect);
    $pdf = new Pdf();
    $pdf->load_html($html_code);
    $pdf->render();
    $file = $pdf->output();
    file_put_contents($file_name, $file);
    
require 'class/class.phpmailer.php';


    //Create a new PHPMailer instance
   $mail = new PHPMailer();
$mail->SMTPDebug = 0;
$mail->IsMail();
$mail->Host = 'localhost';
$mail->Port = 25;
$mail->ssl = false;
$mail->authentication = false;
$mail->addAddress($emaild);
$mail->isHTML = true;
$mail->From = 'hr@sorbeadindia.com';   //Sets the From email address for the message
 $mail->FromName = 'SORBEAD INDIA'; 

$mail->AddAttachment($file_name);
$mail->Subject = "Salary Slip -" . $monthbname." ".$yearb;
$mail->Body = "html";
$mail->AltBody = "alt";
    //Read an HTML message body from an external file, convert referenced images to embedded,
    //convert HTML into a basic plain-text alternative body
    $mail->msgHTML("Salary Slip (".$emp_nameb.") -".$monthbname." ".$yearb);
    //Replace the plain text body with one created manually
    $mail->AltBody = 'Salary Slip ('.$emp_nameb.') -'.$monthbname.' '.$yearb;

    //send the message, check for errors
    if (!$mail->send()) {
        $message = "Mailer Error: " . $mail->ErrorInfo;
    } else {
        $message =  "Message sent!";
    }

    unlink($file_name);
}

?>

我是aws的初学者,所以请帮助我并为这个错误提供一些解决方案。

【问题讨论】:

    标签: amazon-web-services amazon-ec2 smtp phpmailer postfix-mta


    【解决方案1】:

    要修复 SASL 错误并重新生成数据库,请运行以下命令:

    postmap sasl_passwd
    

    您的发送过程如下:

    script -> local mail server -> remote mail server
    

    PHPMailer 负责第一步,您的邮件服务器负责第二步。因此,要解决此问题,您需要查看您的邮件服务器配置。您的 postfix 日志中的其他错误表明您正在尝试通过其他服务器进行中继(在端口 587 上,这将需要 TLS 和身份验证),但是您的配置不正确,因此请搜索如何执行此操作。还要记住,AWS 对从 EC2 实例发送电子邮件施加了严格的限制;他们希望您使用他们的短信服务。

    我还可以看到您使用的是非常旧版本的 PHPMailer,所以upgrade

    您的 PHPMailer 脚本包含以下问题:

    $mail->ssl = false;
    $mail->authentication = false;
    $mail->isHTML = true;
    

    你不能只是编造一些东西并期望它神奇地起作用。

    要关闭加密,请执行以下操作:

    $mail->SMTPSecure = 0;
    

    要禁用身份验证,请执行以下操作:

    $mail->SMTPAuth = false;
    

    要使用 HTML,请执行以下操作:

    $mail->isHTML();
    

    为了让您能够看到脚本传送到 localhost 的进度,请启用调试输出,如下所示:

    $mail->SMTPDebug = 2;
    

    将您的代码基于the examples provided with PHPMailerreading some docs 会揭示这一点。

    您的脚本容易受到 SQL 注入攻击,因为您正在这样做:

    $getid = $_GET['id'];
    $queryd = "SELECT * FROM `salary_sleep_gen` WHERE `id`='$getid'";
    

    也就是说,你之前的:

    if(isset($_POST["action"]))
    

    将阻止该代码工作。要么始终使用$_GET$_POST 之一,要么使用_REQUEST。无论您做什么,请阅读 SQL 注入并修复它,否则您的整个数据库可能会被盗或损坏。

    【讨论】:

      猜你喜欢
      • 2013-07-02
      • 1970-01-01
      • 1970-01-01
      • 2014-07-02
      • 2016-04-22
      • 1970-01-01
      • 2016-10-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多