amazon-web-services - postmap: warning: database /etc/postfix/sasl_passwd.db is older than source file /etc/postfix/sasl_passwd
问题描述
i am working on amazon aws ec2 on server ubuntu 18.04...i am trying to send mail using phpmailer ..when i click to send mail then it shows me mail sent message ...but i didn't received any mails. and when i go to the mail.log file to check what error it shows ..it shows following errors
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
And also here is my php code for mail send:
<?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);
}
?>
i am beginner for aws so Please help me and give some solution for this error.
解决方案
要修复 SASL 错误并重新生成数据库,请运行以下命令:
postmap sasl_passwd
您的发送过程是这样的:
script -> local mail server -> remote mail server
PHPMailer 负责第一步,第二步是你的邮件服务器。因此,要解决此问题,您需要查看您的邮件服务器配置。您的 postfix 日志中的其他错误表明您正在尝试通过其他服务器进行中继(在端口 587 上,这将需要 TLS 和身份验证),但是您的配置不正确,因此请搜索如何执行此操作。还要记住,AWS 对从 EC2 实例发送电子邮件施加了严格的限制;他们希望您使用他们的短信服务。
我还可以看到您使用的是非常旧版本的 PHPMailer,因此请升级.
您的 PHPMailer 脚本包含以下问题:
$mail->ssl = false;
$mail->authentication = false;
$mail->isHTML = true;
你不能只是编造一些东西并期望它神奇地起作用。
要关闭加密,请执行以下操作:
$mail->SMTPSecure = 0;
要禁用身份验证,请执行以下操作:
$mail->SMTPAuth = false;
要说您要使用 HTML,请执行以下操作:
$mail->isHTML();
要让您查看脚本交付到 localhost 的进度,请启用调试输出,如下所示:
$mail->SMTPDebug = 2;
将您的代码基于PHPMailer 提供的示例,或者阅读一些文档会揭示这一点。
您的脚本容易受到 SQL 注入攻击,因为您正在执行以下操作:
$getid = $_GET['id'];
$queryd = "SELECT * FROM `salary_sleep_gen` WHERE `id`='$getid'";
也就是说,你之前的:
if(isset($_POST["action"]))
将阻止该代码工作。要么始终使用$_GET
or之一$_POST
,要么使用_REQUEST
. 不管你做什么,去阅读 SQL 注入并修复它,否则你的整个数据库会被盗或破坏。
推荐阅读
- javascript - JavaScript映射对象不保存对象键?
- mysql - 我怎样才能找到这种时间格式的分钟差异?
- c# - 从文本框后面的代码实时递增计数器
- python - 异常检测python
- django-rest-framework - 是否可以将 TokenObtainPairView (django-rest-frakmework-simplejwt) 端点放在 DRF 上的 Api Root 中?
- angular - Angular 9 和 Ivy 的运行时错误:无法读取未定义的属性“id”;区
- javascript - 正则表达式导致 chrome 挂起 - JS
- .htaccess - .htaccess 在重定向之前满足 www/ssl 规则
- android - 105 char hex 的 Google Play 商店应用签名密钥问题
- python - 使用 Selenium (Chrome) 打印:选择页面