2

I'm trying to sendmail in windows via my gmail account, i've configured my php.ini :

SMTP=smtp.gmail.com
smtp_port=587
[email protected]
sendmail_path="\"C:\xampp\sendmail\sendmail.exe\" -t"

and sendmail.ini :
smtp_server=smtp.gmail.com
smtp_port=587
smtp_ssl=auto
error_logfile=error.log
[email protected]
auth_password=my-password-confident
[email protected]

here is my code :

<?php
// The message
$message = "Line 1\r\nLine 2\r\nLine 3";

// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70, "\r\n");

// Send
$send = mail('[email protected]', 'My Subject', $message);
if ($send) {
    echo "send";
}
else {
echo "fail";}
?>

also i have change my google security become less secure i don't have any idea why, anyone help me ?

7
  • You're not escaping backslashes in the sendmail_path. That doesn't look right to me. Commented Feb 15, 2015 at 23:31
  • it is still fail, i have changed it to sendmail_path="\"C:\\xampp\\sendmail\\sendmail.exe\" -t" Commented Feb 15, 2015 at 23:36
  • I wonder if local server can interact to online server. new for me Commented Feb 15, 2015 at 23:42
  • i don't know Jean Gkol, but it looks like work for some people stackoverflow.com/questions/15965376/… Commented Feb 15, 2015 at 23:45
  • Most of the time you can't send mail from the local server, you need to upload the file to a live server. Commented Feb 16, 2015 at 0:46

2 Answers 2

2

I am not sure if you are using Windows 8 but if you do you must do the following -

1 ) In PHP.ini, make the email part look like this

; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
SMTP = localhost
smtp_port = 465

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = 

; XAMPP IMPORTANT NOTE (1): If XAMPP is installed in a base directory with spaces (e.g. c:\program filesC:\xampp) fakemail and mailtodisk do not work correctly.
; XAMPP IMPORTANT NOTE (2): In this case please copy the sendmail or mailtodisk folder in your root folder (e.g. C:\sendmail) and use this for sendmail_path.  
; XAMPP: Comment out this if you want to work with fakemail for forwarding to your mailbox (sendmail.exe in the sendmail folder)
sendmail_path = "C:\xampp\sendmail\sendmail.exe -t"

; XAMPP: Comment out this if you want to work with mailToDisk, It writes all mails in the C:\xampp\mailoutput folder
;sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe"

; 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(), even in safe mode.
;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

2 ) Make sendmail.ini smtp part look like this

smtp_server=localhost

; smtp port (normally 25)

smtp_port=25

; SMTPS (SSL) support
;   auto = use SSL for port 465, otherwise try to use TLS
;   ssl  = alway use SSL
;   tls  = always use TLS
;   none = never try to use SSL

smtp_ssl=none

; if your smtp server requires authentication, modify the following two lines

[email protected]
auth_password=password

3 ) Download Stunnel https://www.stunnel.org/downloads.html and make the following channges in stunnel.conf. Stunnel is running in the tray, everytime you make changes, right-click the Stunnel icon and Reload the conf file.

cert = stunnel.pem
socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1
key = stunnel.pem
[ssmtp]
accept  = 465
connect = 25
[gmail-smtp]
client = yes
accept = 127.0.0.1:25
connect = smtp.gmail.com:465
; To check logs you can enable logging using following lines
debug = 7

4 ) Go to your Sendmail folder, righclick sendmail.exe -> Properties -> Compatibility -> Click the Make changes for all users button -> Select Windows XP (Service Pack 3) compatibility and tick Run as admin.

5 ) Always start XAMPP as admin!!

This is only needed on Windows 8+ (fex. on Windows 2008 R2 I only needed to properly aim sendmail to gmail and everything was working).

Sign up to request clarification or add additional context in comments.

1 Comment

Select Windows XP (Service Pack 3) is the correct answer for all sendmail problems !! Congratulations
2

to Windows8

after changeing

1-php.ini

2-sendmail.ini

go to C:\xampp\sendmail

  • 1) Right click sendmail.exe and go to properties.
  • 2) click compatibility tab then click change settings for all users.
  • 3) set compatibility mode to Windows XP (Service Pack 3)
  • 4) click the check box for run this progrma as an administrator

Hope that helps someone else.

its working to my

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.