using PHPMailer without configuring SMTP

0

Hi, I'm trying to set up phpmailer for the first time. It has worked perfectly for me through the guides I've read, but I have not found a way to send mail without using SMTP.

I would like to know if there is a way to use it in this way, since I would like it when the emails arrive, where it says "FROM:" appears the email of the sender.

Here my code:

<?php
require("class.phpmailer.php");
require("PHPMailerAutoload.php");
$mail = new PHPMailer();

// VARIABLES
$name = $_POST["name"];
$email = $_POST["mail"];
$message = $_POST["message"];
$emailTo = "[email protected]";
$subject = $_POST["subject"];

//SMTP
//$mail->IsSMTP();
$mail->Host = "smtp.gmail.com";
$mail->Username = '[email protected]';
$mail->Password = 'xxxxxx*';
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Port = 465;

// ENCABEZADO
$mail->setFrom($email, $name);
$mail->addAddress($emailTo, $name);
$mail->Subject = $subject;

// MENSAJE
$mail->Body = $message;

// ENVIAR MENSAJE
if ($mail->send()) {
    echo "<script type='text/javascript'>
            alert('Enviado Correctamente');
          </script>";
} else {
    echo "<script type='text/javascript'>
            alert('No enviado, intentar de nuevo');
          </script>";
}

? >

    
asked by Gaboss 10.04.2017 в 04:41
source

1 answer

2

You can send emails using the php mail function.

On the PHPMailer page itself there is an example:

<?php
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->setFrom('[email protected]', 'Your Name');
$mail->addAddress('[email protected]', 'My Friend');
$mail->Subject  = 'First PHPMailer Message';
$mail->Body     = 'Hi! This is my first e-mail sent through PHPMailer.';
if(!$mail->send()) {
  echo 'Message was not sent.';
  echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
  echo 'Message has been sent.';
}
    
answered by 10.04.2017 в 11:26