Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Definir ruta principal
- define('HOMEDIR',__DIR__);
- use PHPMailer\PHPMailer\PHPMailer;
- use PHPMailer\PHPMailer\Exception;
- require HOMEDIR.'/PHPMailer/Exception.php';
- require HOMEDIR.'/PHPMailer/PHPMailer.php';
- require HOMEDIR.'/PHPMailer/SMTP.php';
- $mail = new PHPMailer(true);
- try {
- //Server settings
- $mail->SMTPDebug = 2; // Enable verbose debug output
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = 'mail.*******.com'; // Specify main and backup SMTP servers
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = 'account@*******.com'; // SMTP username
- $mail->Password = '***********'; // SMTP password
- $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
- $mail->Port = 465; // TCP port to connect to
- //Recipients
- $mail->setFrom('account@********.com', 'Cuentas');
- $mail->addAddress('********@gmail.com'); // Add a recipient
- //$mail->addAddress('[email protected]'); // Name is optional
- //$mail->addCC('[email protected]');
- //$mail->addBCC('[email protected]');
- //Attachments
- //$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
- //$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
- //Content
- $mail->isHTML(true); // Set email format to HTML
- $mail->Subject = 'Bienvenido';
- $mail->Body = 'Te has registrado <b>correctamente</b> en ***** y ahora ya puedes comenzar a usar nuestros servicios.';
- $mail->AltBody = 'Te has registrado correctamente en ********* y ahora ya puedes comenzar a usar nuestros servicios.';
- $mail->send();
- echo 'El mensaje ha sido enviado correctamente';
- } catch (Exception $e) {
- echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement