Viewed   94 times

I have spent all the morning searching this on internet trying to find a solution about this. I have installed wamp server on Windows 8.1 and i'm trying to send some mails with sendmail (http://glob.com.au/sendmail/) and my gmail account

When i configure sendmail to use port nº 465 I always get this error: Socket Error # 10060Connection timed out

If i try to use port nº 587 i get this line on error log: Connection Gracefully. But no email is sent.

This is my sendmail.ini file

[sendmail]
smtp_server=smtp.gmail.com
;I tried both: 587, 465
smtp_port=587
; I tried: "blank, auto ssl, tls, none"
smtp_ssl=
error_logfile=error.log
debug_logfile=debug.log
auth_username=myaccoun@gmail.com
auth_password=mypass
hostname=localhost

And this is php.ini file

[mail function]
smtp_port = 465
sendmail_path="C:wampsendmailsendmail.exe -t"
mail.add_x_header = On

ssl_module is active on apache, and php uses php_open_ssl and php_socket extension.

Also i tried to use stunnel whitout any success

EDIT 27/01/2014

I set smtp_port = 465 and smtp_ssl=ssl on sendmail.ini. Also, I set that sendmail.exe has to run as a Windows XP SP3 programs. After doing that, when I run sendmail.exe on windows console, it sends the email correctly. However, when wamp tries to send mails i get this error on sendmail's error logs.: Socket Error # 10060Connection timed out.

This is the code I'm using to test sendmail:

<?php
$email = "mymail@gmail.com";
$to = "mymail@gmail.com";
$subject = "Hi!";
$body = "Hi,How are you?";
$headers = 'From: ' .$email . "rn".'Reply-To: ' . $email. "rn".'X-Mailer: PHP/' . phpversion();
if (mail($to, $subject, $body, $headers)) echo("<p>Email successfully sent</p>");
else echo("<p>Email delivery failed</p>");
?>

 Answers

3

Finally I found the answer.

The problem is that sendmail has to be run as an administrator. This is the solution to help any one on my situation.

  1. Right click on sendmail.exe
  2. Properties
  3. Compatibility
  4. Change the configuration for all users
  5. Execute as Windows XP SP 3
  6. Execute as adminitrator

And save :D

2 days lost in this nonsense :(

Sunday, August 14, 2022
4

Here's the link that gives me the answer:

[Install] the "fake sendmail for windows". If you are not using XAMPP you can download it here: http://glob.com.au/sendmail/sendmail.zip

[Modify] the php.ini file to use it (commented out the other lines):

[mail function]
; For Win32 only.
; SMTP = smtp.gmail.com
; smtp_port = 25

; For Win32 only.
; sendmail_from = <e-mail username>@gmail.com

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = "C:xamppsendmailsendmail.exe -t"

(ignore the "Unix only" bit, since we actually are using sendmail)

You then have to configure the "sendmail.ini" file in the directory where sendmail was installed:

[sendmail]

smtp_server=smtp.gmail.com
smtp_port=25
error_logfile=error.log
debug_logfile=debug.log
auth_username=<username>
auth_password=<password>
force_sender=<e-mail username>@gmail.com

To access a Gmail account protected by 2-factor verification, you will need to create an application-specific password. (source)

Friday, August 5, 2022
4

Everything you have mentioned is expected behavior. Apache has it's own php.ini version it uses, and require an Apache restart to make any changes effective.

CLI will also have it's own php.ini.

Wednesday, December 21, 2022
2

If you're using *nix, chances are mail() and sendmail() are identical. mail() will still use sendmail, but it passes any arguments you have defined in your php.ini.

The bigger difference is between SMTP and sendmail. If you are doing a lot of mass emailing you want to use SMTP because sendmail opens a new connection for each email which adds quite a bit of overhead.

Monday, November 7, 2022
 
4

Code should be

<?php

    #FileName = "Connection_php_mysql.htm"
    #Type = "MYSQL"
    #HTTP = "true"

    $hostname_Main_DB = "localhost";
    $database_Main_DB = "mydb";
    $username_Main_DB = "root";
    $password_Main_DB = "";

    $con = mysqli_connect($hostname_Main_DB,$username_Main_DB,$password_Main_DB, $database_Main_DB) or die ( "Failed to connect to MySQL: " . mysqli_connect_errno());

    $db=mysqli_select_db($database_Main_DB,$con) or die( "Failed to connect to MySQL: ".mysqli_connect_errno());
?>

You should remove "new". For more information read this

Edit :-

Also you have added . in between two variable that should be ,

$username_Main_DB. $password_Main_DB replace this with $username_Main_DB,$password_Main_DB

Saturday, October 29, 2022
 
cmonkey
 
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :