可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I have installed wamp on windows 8.
Got error:
Warning: mail() [function.mail]: Failed to connect to mailserver at
\"localhost\" port 25, verify your \"SMTP\" and \"smtp_port\" setting in
php.ini or use ini_set() in C:\\wamp\\www\\mail.php on line 9
Here is the simple source 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
mail(\'caffeinated@example.com\', \'My Subject\', $message);
?>
Which software do i have to install to email through php on windows 8? sendmail, msmtp or ssmtp?
回答1:
Try this
Configure This Setups
in php.ini
SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = my-gmail-id@gmail.com
sendmail_path = \"\\\"C:\\xampp\\sendmail\\sendmail.exe\\\" -t\"
in sendmail.ini:
smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=my-gmail-id@gmail.com
auth_password=my-gmail-password
force_sender=my-gmail-id@gmail.com
Important: comment following line if there is another sendmail_path
in the php.ini
: sendmail_path=\"C:\\xampp\\mailtodisk\\mailtodisk.exe\"
Note: Tested and works fine in my Windows 8.1
回答2:
Possible solution. See this question
For me configuring a mail client on localhost is quite difficult. I also tried quite a few times. Later I moved on to other solutions.
You can use SwiftMailer or PhpMailer with some configuration or you can try this tool with zero configuration.
回答3:
On a side note, if you are using your windows PC for development and not as a production server, then I suggest that you don\'t bother setting up a sendmail in windows, just use this handy tool.
Test Mail Server Tool (Its Free)
It will emulate an email server and once any script tries to send an email, it will intercept it and open it for you as an .eml
file, which you can open up in any email reader like outlook or mail viewer(again its free).
Now setting this tool up is just a breez, and you will thank me later for all the time that you saved, from not having to manually setup the sendmail, which I must mention is meant to be on a linux machine. ;)
回答4:
I\'d recommend mercury (http://www.pmail.com/downloads_s3_t.htm - Mercury/32 Mail Transport System for Win32 and NetWare Systems v4.74).
This is included in XAMPP, fairly easy to set up and you don\'t need to configure or (ab)use an email account. You can see the whole smtp transaction in mercury mail log window.
回答5:
Look here for an excellent answer on how to setup mailing from php: PHP mail form doesn't complete sending e-mail
回答6:
Use this function tool:
https://github.com/PHPMailer/PHPMailer
Mail() is prette dificult to use and this function allows you to use the email servers STMP function to send emails.
Read documentation here:
https://github.com/PHPMailer/PHPMailer/blob/master/README.md
回答7:
You need to use email server along with php.
https://www.hmailserver.com/
回答8:
When you are using an e-mail sender functionality through a server that requires SMTP
Authentication, you must need to specify it. And set the host, username and
password (and maybe the port if it is not the default one - 25).
For example, I usually use PHPMailer with similar settings to this ones:
//ini settings
ini_set(\"SMTP\", \"aspmx.l.google.com\");
ini_set(\"sendmail_from\", \"YOURMAIL@gmail.com\");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->CharSet = \'UTF-8\';
$mail->Host = \"mail.example.com\"; // SMTP server example
$mail->SMTPDebug = 0; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Port = 25; // set the SMTP port for the GMAIL server
$mail->Username = \"username\"; //Your SMTP account username example
$mail->Password = \"password\"; //Your SMTP account password example
You can find more about PHPMailer here.
You can video ride for how SMTP configure on wondows here.