Problema con SMTP y PHPMailer
Publicado por Luis (4 intervenciones) el 12/02/2020 16:30:05
He estado trabajando en un proyecto usando PHPMailer durante un tiempo y después de hacer un montón de pruebas, funciona perfectamente bien en mi localhost. Pero ahora estoy teniendo un problema, porque cuando intento enviar mi formulario en el servidor (estoy usando IIS en una PC con Windows 10 y PHP 5.6), ni siquiera carga nada y me salta directamente a la pagina sin haberme notificado que el mensaje se envió correctamente, lo cual es muy extraño porque he visto muchas publicaciones en las que la gente dice que recibe un mensaje de error, pero por alguna razón mi código PHPMailer parece ser completamente ignorado. PHP funciona en mi proyecto porque hay una página de inicio de sesión funcionando, así que realmente no sé qué hacer en este momento. He intentado buscar la opción de Servidor virtual SMTP en IIS pero no la encuentro. He intentado deshabilitar $mail-> IsSMTP (); y no pasa nada. También usando SMTPDebug = 3 y sigo igual. Espero y me puedan ayudar y gracias de antemano.
Tambien intente utilizar este código para probar solamente la función de mail e igualmente no funciono.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require '/PHPMailer/Exception.php';
require '/PHPMailer/PHPMailer.php';
require '/PHPMailer/SMTP.php';
require_once __DIR__ . '/vendor/autoload.php';
$mail = new PHPMailer(true);
try {
//Server settings
$mail->SMTPDebug = 1;
$mail->isSMTP();
$mail->Host = 'mail.domain.com'; // Set the SMTP server to send through
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'email@mycompany.com'; // SMTP username
$mail->Password = 'password'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
//Recipients
$mail->setFrom('email@mycompany.com', $);
$mail->addAddress('email@mycompany.com'); // Add a recipient
$mail->addStringAttachment('stuff');
// Content
$mail->isHTML(true); // Set email format to HTML
//$mail->Subject = $;
//$mail->Body = $;
$mail->Subject = '';
$mail->Body = '';
$mail->CharSet = 'UTF-8';
$mail->send();
echo '<script> alert (".");
windows.history.go(-1);</script>';
} catch (Exception $e) {
echo "";
}
?>
Tambien intente utilizar este código para probar solamente la función de mail e igualmente no funciono.
1
2
3
4
5
6
7
8
<?php
if(mail('user@mydomain.com','test subject','test message')){
echo('ok');
}
else{
echo('not ok');
}
?>
Valora esta pregunta


0