Good morning I am trying to make a program that sends me an email automatically and I looked at several forums to see how to solve the problem as it is change is to change the port but it has not worked in addition to see the documentation in gihub but I have not been able to solve it and I have no ideas to see if someone can colcaborate me and verify the password and mail annex my code I'm trying it from my pc (localhost)
Code
<?php
require("PHPMailer-master/src/PHPMailer.php");
require("PHPMailer-master/src/SMTP.php");
require("PHPMailer-master/src/Exception.php");
$mail = new PHPMailer\PHPMailer\PHPMailer();
$mail->isSMTP();/*Set mailer to use SMTP*/
$mail->Host = 'mail.domain.com';/*Specify main and backup SMTP servers*/
$mail->Port = 465 ;
$mail->SMTPAuth = true;/*Enable SMTP authentication*/
$mail->Username = "[email protected]";/*SMTP username*/
$mail->Password = "******";/*SMTP password*/
$mail->SMTPSecure = 'ssl';//*Enable encryption, 'ssl' also accepted*/
$mail->From = '[email protected]';
$mail->FromName = "esteban";
$mail->addAddress( '[email protected]');/*Add a recipient*/
$mail->addReplyTo('[email protected]', 'esteban');
/*$mail->addCC('[email protected]');*/
/*$mail->addBCC('[email protected]');*/
//$mail->WordWrap = 70;/*DEFAULT = Set word wrap to 50 characters*/
//$mail->addAttachment('../tmp/' . $varfile, $varfile);/*Add attachments*/
/*$mail->addAttachment('/tmp/image.jpg', 'new.jpg');*/
/*$mail->addAttachment('/tmp/image.jpg', 'new.jpg');*/
$mail->isHTML(false);/*Set email format to HTML (default = true)*/
//$mail->Subject = $subject;
$mail->Body = "funciona";
//$mail->AltBody = $message;
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
// header("Location: ../docs/confirmSubmit.html");
echo "funciono";
}
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP=localhost
; http://php.net/smtp-port
;smtp_port=25
smtp_port=25
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = [email protected]
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;sendmail_path =
; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail().
;mail.force_extra_parameters =
; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header=On
; The path to a log file that will log all mail() calls. Log entries include
; the full path of the script, line number, To address and headers.
;mail.log =
; Log mail to syslog (Event Log on Windows).
;mail.log = syslog
Message could not be sent.Mailer Error: SMTP connect () failed. link