mail() php function not working in Laragon


  • | 1422 points

    I just installed Laragon (2.1.2 161027) on my freshly installed Windows 10 and I can't make mail() function work. It works perfectly when I try it in Laragon Mail Analyzer:

    0_1478017120616_help.png

    but not on mail() function of PHP. My PHP version is 7.0.12 and here's the exact mail function code in my php script:

    mail('*********@outlook.ph', 'Example', 'Example message');
    

    I already tried different email address but still nothing.

    Here's my php.ini [mail function] codes:

    [mail function]
    ; For Win32 only.
    ; http://php.net/smtp
    SMTP = localhost
    ; http://php.net/smtp-port
    smtp_port = 25
    
    ; For Win32 only.
    ; http://php.net/sendmail-from
    ; sendmail_from = me@example.com
    
    ; 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
    sendmail_path="D:/Others/laragon/bin/sendmail/sendmail.exe"
    
    ; 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
    

    Thanks in advance for the help.

    Update: Perfectly works on my laptop but not on my freshly installed Windows 10 desktop (PC), I don't know what's going on.

    I tried to put success and failed indicator on the script (the if/else):

    $value = mail('*********@outlook.ph', 'My Subject', 'Message');
    
    if($value) {
      echo 'Message sent!';
    }
    else {
      echo 'Message sending failed!';
    }
    

    When I enable the gmail as mail sender, it gives me failed error but when I disable it, it gives me success or 'Message sent'.

    Anyone who has an idea on what's going on? I can't find any logs so I don't really know where should I start the fixing, so I need someone's help.


  • administrators
    | 43892 points

    Did you receive your test emails?


  • | 1422 points

    Yes, I can receive that but not the php mail() function.


  • administrators
    | 43892 points

    Hmm, I suspect if your firewall or antivirus caused the issue but as you said it is a fresh Windows 10, I have no clue.

    You may check the logs in Menu > PHP > Mail Sender > debug.log & error.log


  • | 1422 points

    I have installed anti-virus with personal firewall before I install Laragon so your suspect might be the case. I will try to disable the personal firewall or uninstall my anti-virus and test if it will fix the problem and update this thread later. Thanks for the help.

    Update: I've checked the error.log and I got this message:

    16/11/03 13:41:07 : Must issue a STARTTLS command first. c2sm8883042pal.42 - gsmtp<EOL>

  • administrators
    | 43892 points

    @woenel : How about your debug.log?


  • | 1422 points

    I got this log from debug.log:

    16/11/03 22:48:34 ** --- MESSAGE BEGIN ---
    16/11/03 22:48:34 ** To: ***********@outlook.ph
    16/11/03 22:48:34 ** Subject: My Subject
    16/11/03 22:48:34 ** X-PHP-Originating-Script: 0:index.php
    16/11/03 22:48:34 ** 
    16/11/03 22:48:34 ** Message content.
    16/11/03 22:48:34 ** --- MESSAGE END ---
    16/11/03 22:48:34 ** Failed to load SSL libraries: Could not load SSL library.
    16/11/03 22:48:34 ** Connecting to smtp.gmail.com:587
    16/11/03 22:48:35 ** Connected.
    16/11/03 22:48:35 << 220 smtp.gmail.com ESMTP f62sm13438839pfg.18 - gsmtp<EOL>
    16/11/03 22:48:35 >> EHLO laragon.org<EOL>
    16/11/03 22:48:35 << 250-smtp.gmail.com at your service, [121.54.44.93]<EOL>250-SIZE 35882577<EOL>250-8BITMIME<EOL>250-STARTTLS<EOL>250-ENHANCEDSTATUSCODES<EOL>250-PIPELINING<EOL>250-CHUNKING<EOL>250 SMTPUTF8<EOL>
    16/11/03 22:48:35 ** Authenticating as ***********@gmail.com
    16/11/03 22:48:35 >> MAIL FROM: <***********@gmail.com><EOL>
    16/11/03 22:48:36 << 530 5.7.0 Must issue a STARTTLS command first. f62sm13438839pfg.18 - gsmtp<EOL>
    16/11/03 22:48:36 ** Disconnecting from smtp.gmail.com:587
    16/11/03 22:48:36 ** Disconnected.
    16/11/03 22:48:36 ** Disconnected.
    16/11/03 22:48:36 ** Must issue a STARTTLS command first. f62sm13438839pfg.18 - gsmtp<EOL>

  • administrators
    | 43892 points

    @woenel: The root cause is:

    16/11/03 22:48:34 ** Failed to load SSL libraries: Could not load SSL library.

    On bin\sendmail folder, you should have:
    libeay32.dll
    ssleay32.dll

    If you already have them, you can try deleting them and re-install Laragon over.


  • | 1422 points

    Not even deleting those libraries and reinstalling the Laragon fixed the problem. I've downloaded the libeay32.dll and ssleay32.dll from the web and replaced the current one and it finally works but I still don't know what causes the problem since it works on my laptop without doing anything like that. The only difference between my laptop and desktop is my desktop is 32 bit while my laptop is 64 bit. I have no idea though.

    Thanks @leokhoa, my problem is now fixed.


  • | 884 points

    I can not send emails. My setup is Windows 10 with Laragon 2.1.3.
    Entered my Google Credentials into the settings into Email-Sender.
    Sending the test email from within Laragon app works.
    It does not work if I use the PHP mail() function:

    Here is an excerpt of my debug.log. Seems Google wants some authentication.
    What can I do?

    16.11.17 16:43:57 << 220 smtp.gmail.com ESMTP jx8sm3904303wjc.2 - gsmtp<EOL>
    16.11.17 16:43:57 >> EHLO laragon.org<EOL>
    16.11.17 16:43:57 << 250-smtp.gmail.com at your service, [37.201.242.53]<EOL>250-SIZE 35882577<EOL>250-8BITMIME<EOL>250-STARTTLS<EOL>250-ENHANCEDSTATUSCODES<EOL>250-PIPELINING<EOL>250-CHUNKING<EOL>250 SMTPUTF8<EOL>
    16.11.17 16:43:57 >> STARTTLS<EOL>
    16.11.17 16:43:57 << 220 2.0.0 Ready to start TLS<EOL>
    16.11.17 16:43:57 >> EHLO laragon.org<EOL>
    16.11.17 16:43:57 << 250-smtp.gmail.com at your service, [37.201.242.53]<EOL>250-SIZE 35882577<EOL>250-8BITMIME<EOL>250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH<EOL>250-ENHANCEDSTATUSCODES<EOL>250-PIPELINING<EOL>250-CHUNKING<EOL>250 SMTPUTF8<EOL>
    16.11.17 16:43:57 >> MAIL FROM: <processwire@dclone.dev><EOL>
    16.11.17 16:43:57 << 530-5.5.1 Authentication Required. Learn more at<EOL>530 5.5.1  https://support.google.com/mail/?p=WantAuthError jx8sm3904303wjc.2 - gsmtp<EOL>
    16.11.17 16:43:57 ** Disconnecting from smtp.gmail.com:587
    16.11.17 16:43:57 ** Disconnected.
    16.11.17 16:43:57 ** Disconnected.
    16.11.17 16:43:58 ** Authentication Required. Learn more at<EOL> https://support.google.com/mail/?p=WantAuthError jx8sm3904303wjc.2 - gsmtp<EOL>

  • administrators
    | 43892 points

    @jmartsch: On your Gmail account's security settings and set permissions for "Less secure apps" to Enabled
    https://www.google.com/settings/security/lesssecureapps


Log in to reply
 

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