
Estoy ejecutando postfix con dovecot. Estoy intentando utilizar el paquete PHP Pear Mail para enviar correos electrónicos, pero no consigo que funcione. El error que me sale es este: authentication failure [SMTP: STARTTLS failed (code: 220, response: 2.0.0 Ready to start TLS)]
.
Lo estoy ejecutando usando php 7.4 cli. Este es el archivo (mail-test.php):
<?php
require_once "Mail.php";
$from = "[email protected]";
$to = '[email protected]';
$host = "mail.fildom.net";
$port = "25";
$username = 'username';
$password = 'password';
$subject = "test";
$body = "test";
$headers = array ('From' => $from, 'To' => $to,'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo($mail->getMessage());
} else {
echo("Message successfully sent!\n");
}
?>
Probé muchas soluciones en línea, como configurar verificar_peer y verificar_peer_name, pero ninguna funcionó. Intenté configurar el puerto en 567 pero aparece el mismo error.
Este es mi archivo de configuración postfix (main.cf):
# GENERAL SETTINGS
smtpd_banner = $myhostname ESMTP $mail_name
biff = no
append_dot_mydomain = no
readme_directory = no
# SMTP SETTINGS
smtp_use_tls=yes
smtp_tls_security_level = may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
# SMTPD SETTINGS
smtpd_use_tls=yes
smtpd_tls_security_level = may
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_tls_cert_file=/etc/ssl/cert.pem
smtpd_tls_key_file=/etc/ssl/key.pem
smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
# SASL SETTINGS
smtpd_sasl_auth_enable = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
# VIRTUAL MAIL BOX AND LMTP SETTINGS
virtual_transport = lmtp:unix:private/dovecot-lmtp
virtual_mailbox_domains = /etc/postfix/virtual_mailbox_domains
# OTHER SETTINGS
myhostname = mail.fildom.net
myorigin = /etc/mailname
mydestination = localhost.$mydomain, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
Obtuve los certificados SSL de CloudFlare. También configuré y habilité las extracciones de origen autenticado en CloudFlare, pero no estoy seguro de si esto tiene algún efecto.
Gracias de antemano.