how send emails with PHPMailer?

  • | 568 points

    I usually work in xampp server but I would like work in laragon, but I can't send emails with library PHPMailer, I work very much in this library.

    not show any error.
    help me please, thank you

  • administrators
    | 132054 points

    @gabgustavo : Laragon's Mail Analyzer (Menu > Preference > Mail Sender > Test Sending Email) uses PHPMailer without any issue.
    Please give me more information so I can help.

  • | 568 points

    Thank you, I have the setting of Phpmailer similary to this link:
    but with more parameters. I use psr4 in the sistems.
    Message that generate:
    Laragon with authentication:
    SMTP -> ERROR: Failed to connect to server: (0)
    The following From address failed:
    Laragon without authentication:
    show a message with a checkbox and the message: =?UTF-8Q?AndMySubject
    xampp with or without authentication no problem to send emails

    Thank per you collaboration

  • administrators
    | 132054 points

    @gabgustavo : This code works for me:

    require_once 'PHPMailerAutoload.php';
    $mail = new PHPMailer();
    $mail->CharSet = 'UTF-8';
    $to               = '';
    $username         = '';
    $password         = 'xxxx';
    echo 'Welcome to Laragon Mail Analyzer...';
    $subject          = 'Laragon Mail Analyzer: Congratulations! Your configuration is OK';
    $body             = '<p>It means you can use mail() function to send email to Internet easily with Laragon. Let\'s try:</p>
    <p style="font-weight: bold; margin: 15px;">mail(\'\', \'Hi leokhoa\', \'I like Mail Sender feature.\');</p><p>Enjoy programming :)</p>' . '<div>Best wishes,</div><div>Laragon.</div>';
    $mail->SMTPOptions = array(
        'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
    $mail->SMTPDebug  = 2;                     
    $mail->SMTPAuth   = true;                  
    $mail->SMTPSecure = 'tls';                 
    $mail->Host       = '';      
    $mail->Port       = 587;                   
    $mail->Username   = $username;  
    $mail->Password   = $password;            
    $mail->SetFrom($username, 'Blah');
    $mail->Subject    = $subject;
    $address = $to;
    $mail->AddAddress($address, 'Blah');
    if(!$mail->Send()) {
      echo 'Mailer Error: ' . $mail->ErrorInfo;
    } else {
      echo 'Message sent successfully!';

  • | 568 points

    Hi, this is my code, in local doesn't work, I have that loads to a production server

    //method to send email
    public static function sendWeb($FromName, $Subject, $addAddress, $addAddressName, $msgHTML, $from="",$adjunto=""){
    //Create a new PHPMailer instance
    $mail = new PHPMailer;
    $mail->CharSet = 'UTF-8';
    //indico a la clase que use SMTP
    //permite modo debug para ver mensajes de las cosas que van ocurriendo
    $mail->SMTPDebug = 1;

    	//Debo de hacer autenticación SMTP
    	$mail->SMTPAuth = true;
    	//$mail->SMTPSecure = "tls";
    	//$mail->SMTPSecure = "ssl";
    	// $mail->Host = "ssl://";
    	$mail->Port = 587;
    	$mail->Host = "";
    	//indico un usuario / clave de usuario de gmail
    	$mail->Username = "";
    	$mail->Password = "xxxxxxx";
    	  	$mail->From = "";
        	$mail->From = "$from";
    	$mail->FromName =" $FromName";
    	$mail->Subject = $Subject. ' - ' . date('H:i:s');
    	//Attach an image file
    	// if(@$adjunto['size']>0){
    	// 	$mail->addAttachment($adjunto['tmp_name'],$adjunto['name']);
    	// }
    	// echo "<pre>";
    	// dd($mail->send());
    	// echo "</pre>";
    	if($mail->send()) return true;
    	else return false;

Log in to reply

Looks like your connection to Laragon was lost, please wait while we try to reconnect.