skip to Main Content

I have installed WAMP Server on my Windows 10 PC and when I try to send emails through a valid SMTP configuration it doesn’t work. The same SMTP configuration works on another LAMP installation and also on a live server.

When I try sending the email through a PrestaShop installation I get following error:

Error: Please check your configuration
Connection could not be established with host smtp.gmail.com [ #0]

And with Magento I get following error:

SMTP Pro Self Test Results
Sending test email to your contact form address: [email protected] from: [email protected]. Unable to send test email.
Exception message was: Could not open socket
Please check the user guide for frequent error messages and their solutions.
Default templates exist.
Email communications are enabled.

As per my understanding, this issue is not dependent on Magento or PrestaShop, it is coming because of the WAMP installation.

Do I have to enable some extension or something for the WAMP installation? Or have I missed something else?

Please help. Already wasted a lot of time investigating and trying solutions from the Web, but nothing seems to be working.

5

Answers


    1. make sure that your –

                       extension=php_openssl.dll
                       extension=php_sockets.dll
      

    is enable in php.ini file.

    1. check is Enable ssl_module under Apache Module.
    Login or Signup to reply.
  1. These are possibly causes which prevent you from sending mails via WAMP server.

    • Your firewall configurations may (by default) block some ports used by WAMP for sending emails.
    • These ports may be already used by your others applications. Prefer to this to know which port is being used by which application.
    • Administrators rights are required for the WAMP server to be able to send mail. Run the server as administrator.

    Since you’re sure that settings have already worked on a server so I assume there nothing to check with PHP.ini

    Login or Signup to reply.
  2. Download the sendmail.zip

    Create a folder named “sendmail” in “C:wamp”.
    Extract these 4 files in “sendmail” folder: “sendmail.exe”, “libeay32.dll”, “ssleay32.dll” and “sendmail.ini”.
    Open the “sendmail.ini” file and configure it as following

    smtp_server=smtp.gmail.com
    smtp_port=465
    smtp_ssl=ssl
    default_domain=localhost
    error_logfile=error.log
    debug_logfile=debug.log
    auth_username=[your_gmail_account_username]@gmail.com
    auth_password=[your_gmail_account_password]
    pop3_server=
    pop3_username=
    pop3_password=
    force_sender=
    force_recipient=
    hostname=localhost
    

    You do not need to specify any value for these properties: pop3_server, pop3_username, pop3_password, force_sender, force_recipient. The error_logfile and debug_logfile settings should be kept blank if you have already sent successful email(s) otherwise size of this file will keep increasing. Enable these log file settings if you don’t get able to send email using sendmail.

    Enable IMAP Access in your GMail’s Settings -> Forwarding and POP/IMAP -> IMAP Access:

    Enable “php_openssl” and “php_sockets” extensions for PHP compiler:
    
    Open php.ini from “C:wampbinapacheApache2.2.17bin” and configure it as following (The php.ini at “C:wampbinphpphp5.3.x” would not work) (You just need to configure the last line in the following code, prefix semicolon (;) against other lines):
    

    Restart WAMP Server.
    Create a PHP file and write the following code in it:

    <?php
    $to       = '[email protected]';
    $subject  = 'Testing sendmail.exe';
    $message  = 'Hi, you just received an email using sendmail!';
    $headers  = 'From: [your_gmail_account_username]@gmail.com' . "rn" .
                'MIME-Version: 1.0' . "rn" .
                'Content-type: text/html; charset=utf-8';
    if(mail($to, $subject, $message, $headers))
        echo "Email sent";
    else
        echo "Email sending failed";
    ?>
    

    Make appropriate changes in $to and $headers variables to set recipient and sender (“From” header) addresses. Save it as “send-mail.php”. (You can save it anywhere or inside any sub-folder in “C:wampwww”.)
    Open this file in browser, it MUST work now

    Login or Signup to reply.
  3. You can use PHP Mailer or Download php mailer with example from here. Once you setup the phpmailer with your project use following code to send mail using gmail SMTP :

    require_once('inc/class.phpmailer.php');        # INCLUDE PHPMailer CLASS FILE
    require_once("inc/class.smtp.php");                 # INCLUDE OTHER SMTP FILE
    

    Include above files in your project or PHP file which you use to send email and then :

    $mail             = new PHPMailer();
    
    $mail->IsSMTP(); 
    $mail->SMTPDebug  = 0;                      # ENABLE SMTP DEBUG INFORMATION (FOR TESTING)
                                                # 1 = ERROR AND MESSAGE
                                                # 2 = MESSAGE ONLY
    $mail->SMTPAuth   = true;                   # ENABLE SMTP AUTHENTICATION
    $mail->Host       = "Host Addresss";        # smtp.gmail.com
    $mail->Port       = 587;                    # PORT NUMBER
    $mail->Username   = "[email protected]";        # SMTP EMAIL USER NAME
    $mail->Password   = "xxxxxxx";          # SMTP ACCOUNT PASSWORD
    $mail->SetFrom('[email protected]', 'Test Name');
    $mail->SMTPSecure = 'tls';
    $mail->AddReplyTo("[email protected]","SMTP TEST");
    $v_Msg ="This is a test message via SMTP";
    
    $mail->Subject    = "EMAIL SUBJECT";
    
    $mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; # OPTIONAL
    $address = "[email protected]";          # ADDRESS WHERE YOU WANT TO SEND MAIL
    $mail->AddAddress($address, "TESTING");
    $mail->MsgHTML($v_Msg);                 # EMAIL CONTENT
    
    if(!$mail->Send()) {                    
        echo "Mailer Error: " . $mail->ErrorInfo;   # ERROR MESSAGE, IF MAIL NOT SENT SUCCESSFULLY 
    }else {
        echo "Message sent!";               # SUCCESS MESSAGE
    }
    

    NOTE : Make sure your smtp gmail account must be Allow less secure apps: ON. You can turn on less secure apps for your gmail
    account using THIS URL

    Login or Signup to reply.
  4. Sometimes its easier not to rely on your own smtp server. (firewalls everywhere)

    You can experiment with some other online mail delivery services than gmail, like mailgun or sendgrid.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search