Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
401 views
in Technique[技术] by (71.8m points)

php - sendmail.exe opens on sending mail

I am actually new in using sendmail but I have read a lot about this, and only redirect me to use PHPmailer,swiftmailer etc... But it's so complicated to understand without the knowledge of the basics. So I decided to try simple, and this is what I've got.

I have configured my php.ini:

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

And my sendmail.ini:

[sendmail]
smtp_server=smtp.gmail.com
smtp_port=587
smtp_ssl=
error_logfile=error.log
debug_logfile=debug.log
[email protected]
auth_password=mypassword
hostname=localhost

and I have this PHP code:

$to      = '[email protected]';
$message = $_POST['message'];
$email = $_POST['email'];
$contact_num = $_POST['contact_number'];
$headers = 'From:'.'$email' . "
" .'$contact' . "
" .
'Reply-To: [email protected]' . "
" .
'X-Mailer: PHP/' . phpversion();

mail($to, $message, $headers);

but whenver i click the submit button the sendmail.exe appears and nothing happens. And when I check the error.log it says:

14/07/01 23:23:48 : Connection Closed Gracefully.
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This part is a copy & paste of post: Sendmail Wamp Php

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

    if you using gmail you need create new password "Your application-specific passwords"

If that still dosen't work (My answer)

Make sure the server (or IDE) is being run as admin, by either:

1) Right clicking the program (e.g. server, ide, command prompt) and clicking "Run as Administer"

2) OR Right click program> properties> compatiblity> Tick execute as admin

For instance if your using the PHP in built server, run the command prompt as admin and start the server as normal using

C:wampinphpphp5.5.12php.exe -S localhost:80 -t C:Userspatho
ootFolder

Of course change the file paths to suit your needs.

EDIT: This is probally the bug you headed into https://bugs.php.net/bug.php?id=44994


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...