xampp发送电子邮件不起作用

时间:2014-12-25 15:24:34

标签: php email xampp

我正在尝试使用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!'); } ?>

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

2 个答案:

答案 0 :(得分:0)

您是如何尝试发送邮件的?是来自localhost吗?

如果来自localhost,您可以在Windows中以PHP格式从XAMPP或WAMP(localhost)发送电子邮件。

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 .

答案 1 :(得分:0)

如果您的smtp电子邮件地址为PixelatedPig9977@gmail.com,而您用来发送电子邮件并收到相同的电子邮件地址PixelatedPig9977@gmail.com,那么您的电子邮件无法显示在收件箱中,它应位于{{ 1}} All Mail已经From: me