Mail of PHP, DNS request timed out, and FQDN

2019-07-18 19:28发布

I want to make mail() of PHP work in my Windows Server 2012 R2. To this end, I first installed SMTP by following this page.

One thing that confuses me is the Full-qualified domain name. WIN-RFELH8GM0KN is what it proposes by default. My server hosts several websites, does anyone know which website I should specify here?

I did not change this, as a consequence, mail www.google.com in nslookup returns DNS request timed out. So is it an error?

enter image description here

Of cause, my test.php does not send the mail:

<?php
mail('mymail@gmail.com', 'title', 'content');
?>

Could anyone help?

Update 1 Following the answer of @LittleAI , I started SMTP, but DNS request timed out is still there:

enter image description here

Update 2 Here is php.ini:

enter image description here

telnet localhost 25 returns the follows:

enter image description here

Update 3 Here was a test, which worked well: I did receive the test mail in the inbox of softtitmur@gmail.com. However, if I redo the test in Update 1, there is still DNS requested time out.. And test.php still cannot send the mail...

enter image description here

Update 4 I just realised that in the page I followed, it is mail.vsysad.com under nslookup (I thought it was mail vsysad.com, that is why i tried mail www.google.com which did not make sense). So it works also in my server, and there is no DNS request timed out.

enter image description here

Then, I double checked php.ini, I realised that sendmail_from was not uncommented. So I uncommented it and set sendmail_from = softtimur@gmail.com, as a result, mail() of php works now, so the problem is solved, though I still don't understand FQDN and its default value (ie, WIN-RFELH8GM0KN)...

1条回答
时光不老,我们不散
2楼-- · 2019-07-18 20:24

The first thing I noticed is that your SMTP Virtual service in IIS is not in a starting state so this would cause an issue. Make sure this service is in a starting state before testing.

The FQDN name is mainly used for the SMTP banner which the sender will be presented when connecting over port 25 to your server.

It maybe worth installing the DNS role onto your server and create a forward lookup zone referencing a fake domain e.g test.com and create an a record within this zone called SMTP using your servers IP. Make sure to then set your server to use 127.0.0.1 as the DNS provider so it can check record before delegating the reponse to root hints/external dns forwarder.

You need to do an SMTP request using Telnet to confirm SMTP is listening on port 25. You can do this by using the localhost ip address (127.0.0.1) as shown below:

  telnet 127.0.0.1 25
  helo test.com
  MAIL FROM: ****YOUR EMAIL ACCOUNT****
  RCPT TO: ****SENDERS ADDRESS****
  DATA

You would probably not receive the email from your relay to GMAIL due to SPF Record which is in place that only allows certain IP/hostnames to send as google.com, but for testing you should see your server receive the mail after data has been inputted.

Here is the guide for using telnet on your server. Just make sure you have telnet feature installed as this is not installed by default.

http://www.yuki-onna.co.uk/email/smtp.html

Additional:

 telnet localhost 25

After the SMTP banner type the following command in but make sure not to make any mistakes or else you'll need to probably start your sesssion all over again.

 helo test.com

You should then see a 250 response to say the server is listening

The type the following:

MAIL FROM: test@test.com

It should respond with OK. If so, then type:

RCPT TO: ***YOU EMAIL ADDRESS OF CHOICE****

Again, it should respond with OK. If so, type the following:

DATA

Press enter after the DATA command. Your now into the body of the email. For testing purposes we will miss the subject bar and just add some data to the body.

  This is a test email.

Then to complete the email you need to leave a blank line by pressing return, then a full stop, then return again like so.

    ***BLANK LINE****
    .
    ***Hit Return****

Screenshot all the commands but you can blank out the email so I can see the output.

查看更多
登录 后发表回答