Ask Your Question

phpmailer does not work

asked 2012-11-02 05:46:16 -0500

oggie0563 gravatar image

updated 2012-11-02 07:08:18 -0500

hhlp gravatar image

I am trying a PHPMailer test using Gmail as a host ssl and I get the following exceptions,

SMTP -> ERROR: Failed to connect to server: php_network_getaddresses: getaddrinfo failed: Name or service not known (0)
SMTP Error: Could not connect to SMTP host.

Here is my code,

$mail = new PHPMailer(true); 

try {
$nombre_emisor="Dani Filth";
$nombre_destino="Pepe Lara";

$mail->SMTPDebug  = 2;
$mail->SMTPAuth   = true;
$mail->SMTPSecure = "ssl";
$mail->Host       = "";
$mail->Port       = 465;
$mail->Username   = $correo_emisor;
$mail->Password   = $contrasena;

$mail->AddReplyTo($correo_emisor, $nombre_emisor);
$mail->AddAddress($correo_destino, $nombre_destino);
$mail->SetFrom($correo_emisor, $nombre_emisor);
$mail->Subject = 'Prueba de phpMailer en Garabatos Linux';
$mail->AltBody = 'Hijole para ver el mensaje necesita un cliente de correo compatible con HTML.';
$mail->MsgHTML("<strong>¿Que otro nombre recibe el área de sol del Estadio Cuscatlán?</strong>");

echo "Mensaje enviado. Que chivo va vos!!";

} catch (phpmailerException $e) {
echo $e->errorMessage();
} catch (Exception $e) {
echo $e->getMessage();

I am based on 'Using Apache and SELinux together' from Using Apache and SELinux together

I have left the default SELinux and enabled the audit.log file but I do not see anything wrong.

I can not understand why it does not work. In my last OS Ubuntu it works fine.

Please help!!

Kind regards.

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2012-11-02 23:21:36 -0500

oggie0563 gravatar image

updated 2012-11-03 02:25:09 -0500

Yes, resolved!

I have gotten the information from the web Apache and SELinux

I am meaning about the paragraph at the displayed page,

SELinux policy is customizable based on least access required. So by default SElinux prevents certain http scripts from working. httpd policy is extremely flexible and has several booleans that allow you to manipulate the policy and run httpd with the tightest access possible. Here is the process for changed the status of these booleans for the Apache Web Server.



Disable PHP

You will need to manage the PHP settings for SELinux in order to run PHP.

setsebool -P httpd_builtin_scripting 0

I have set SELinux to my own needed configuration but the above option is enough.

Kind regards,


edit flag offensive delete link more

answered 2012-11-04 02:45:52 -0500

oggie0563 gravatar image


About my question only if I restart httpd.service on the booted system I can send mails.

On the other hand both irqbalance.service and httpd.service are enabled and running except irqbalance.service that are not running (only enabled).

I do not know if these questions are the reason I can not send mails until restart httpd.service

Any suggestion will be appreciated.



edit flag offensive delete link more

Question Tools


Asked: 2012-11-02 05:46:16 -0500

Seen: 1,714 times

Last updated: Nov 04 '12