XAMPP发送电子邮件不起作用


xampp send email not working

我正在尝试使用xampp发送电子邮件。我一直在php.ini和sendmail.ini但它不起作用!我尝试使用此代码。

    <?php $to = 'PixelatedPig9977@gmail.com'; $subject = 'Fake sendmail test'; $message = 'If we can read this, it means that our fake Sendmail setup works!'; $headers= 'From:willlun66@live.se'."'r'n" ; if(mail($to, $subject, $message, $headers)) { echo 'Email sent successfully!'; } else {  die('Failure: Email was not sent!'); } ?>

它说电子邮件已成功发送,但我的电子邮件中没有任何内容!

您是如何尝试发送邮件的? 是来自本地主机吗?

如果来自本地主机,您可以在Windows中的PHP中从XAMPP或WAMP(本地主机)发送电子邮件。

a) Open the "php.ini". For XAMPP,it is located in C:'XAMPP'php'php.ini. Find out if you are using WAMPP server.
Note : Make a backup of php.ini file
b) Search [mail function] in the php.ini file.
You can find like below.
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = postmaster@localhost
Change the localhost to the smtp server name of your ISP. No need to change the smtp_port. Leave it as 25.
Change sendmail_from from postmaster@localhost to your domain email address which will be used as from address..
So , it will become like this.
[mail function]
; For Win32 only.
SMTP = smtp.planetghost.com
smtp_port = 25
; For Win32 only.
sendmail_from = info@planetghost.com
c) Restart the XAMPP or WAMP(apache server) so that changes will start working.
d) Now try to send the mail using the mail() function .

如果您的 SMTP 电子邮件地址是您用来发送电子邮件和接收到同一电子邮件地址PixelatedPig9977@gmail.com,那么您的电子邮件无法显示在收件箱PixelatedPig9977@gmail.com,它应该与From: me All Mail,并且已经set as read