php - PHPMailer error php_network_getaddresses: getaddrinfo failed: Name or service not known
Get the solution ↓↓↓i create code for send email using php mailer and its work in localhost but when i run on live server show error bellow :
2020-11-16 07:45:03 SMTP ERROR: Failed to connect to server: php_network_getaddresses: getaddrinfo failed: Name or service not known (0) 2020-11-16 07:45:03 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
sendmail php code :
<?php
/**
* This example shows sending a message using a local sendmail binary.
*/
require 'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail->SMTPDebug = 2;
$mail->isSMTP();
$mail->Host = 'mail.domain.co.id';
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = 'XXXXXXXXXX';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->setFrom('[email protected]');
$mail->addReplyTo('[email protected]');
$mail->addAddress('[email protected]');
$mail->Subject = 'Test Email via Mailtrap SMTP using PHPMailer';
$mail->isHTML(true);
$mailContent = "<h1>Send HTML Email using SMTP in PHP</h1>
<p>This is a test email I'm sending using SMTP mail server with PHPMailer.</p>";
$mail->Body = $mailContent;
if($mail->send()){
echo 'Message has been sent';
}else{
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
}
now im running in ubuntu server 12.04 LTS, is there any misconfiguration in my server?
Answer
Solution:
The answer is in the error message:
php_network_getaddresses: getaddrinfo failed: Name or service not known
This means one of two things:
mail.domain.co.id
is the wrong name for your mail server- Your DNS service isn't working
This has nothing to do with your script, and everything to do with either your settings or your server's network.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: videoxxx
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.