no SMTP support in Laragon besides gmail?


  • | 115 points

    after failing to use laragon/sendmail with an external SMTP server for quite some time and not finding any tutorials and exlpanations on this im starting to think it simply is not possible to do so?
    i can use laragon only with the integrated gmail solution in order to send mails?


  • | 16270 points

    @rbbrtoy have you tried mailhog?


  • | 16270 points

    @rbbrtoy here is some information on how to send email using PHPMailer.

    In your project require PHPMailer

    composer require phpmailer/phpmailer
    

    Find your SMTP setting

    You need your SMTP settings from your ISP. It should look like this:

    0_1629844513153_upload-8f35f028-f115-4a1f-9b09-c8b7e0fe66f2

    Use an example script

    You will need to modify it with your ISP settings. My ISP only requires the outgoing mail server and port (STARTTLS is
    Yes based on the port 587), I therefore used
    the smtp_no_auth.phps script as my
    starting point.

    <?php
    //Import PHPMailer classes into the global namespace
    //These must be at the top of your script, not inside a function
    use PHPMailer\PHPMailer\PHPMailer;
    use PHPMailer\PHPMailer\SMTP;
    use PHPMailer\PHPMailer\Exception;
    
    //Load Composer's autoloader
    require '../vendor/autoload.php';
    
    try {
    
    //Create an instance; passing `true` enables exceptions
        $mail = new PHPMailer(true);
    //Tell PHPMailer to use SMTP
        $mail->isSMTP();
    //Enable SMTP debugging
    //SMTP::DEBUG_OFF = off (for production use)
    //SMTP::DEBUG_CLIENT = client messages
    //SMTP::DEBUG_SERVER = client and server messages
        $mail->SMTPDebug = SMTP::DEBUG_SERVER;
    
    //Set the hostname of the mail server
        $mail->Host = 'relay.plus.net';
    //Set the SMTP port number - likely to be 25, 465 or 587
        $mail->Port = 587;
    
    //We don't need to set this as it's the default value
    //$mail->SMTPAuth = false;
    //Set who the message is to be sent from
        $mail->setFrom('from@example.com', 'Michael Pritchard');
    //Set an alternative reply-to address
    //    $mail->addReplyTo('replyto@example.com', 'First Last');
    //Set who the message is to be sent to
        $mail->addAddress('my-email@my-isp.com', 'Michael Pritchard');
    //Set the subject line
    //    $mail->Subject = 'PHPMailer SMTP without auth test';
    //Read an HTML message body from an external file, convert referenced images to embedded,
    //convert HTML into a basic plain-text alternative body
    //Replace the plain text body with one created manually
    //    $mail->AltBody = 'This is a plain-text message body';
    //Attach an image file
    
        //Content
        $mail->isHTML(true);                                  //Set email format to HTML
        $mail->Subject = 'Here is the subject';
        $mail->Body = 'This is the HTML message body <b>in bold!</b>';
        $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
    
        $mail->send();
        echo 'Message has been sent';
    } catch (Exception $e) {
        echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
    }
    

    Send it!

    Then you can use the example from PHPMailer to send an email.

    0_1629844816553_upload-8d323a90-942a-47ae-94db-289ee2de7cdb

    You will need to adjust the script you use based on your authentication and setting from your ISP.

    I hope this helps, keep trying 😊


Log in to reply
 

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