# Multiple websites using Sendmail



## BernardoCR (Mar 19, 2014)

Hello guys,

I have multiple websites written in PHP running on the same dedicated server, and I'm having problems with Sendmail. PHP's sendmail method uses the main IP of the server for sending e-mails. For example: 0.1.2.3. Lately, I'm getting this message when trying to send e-mail to certain providers:

```
Deferred: 450 4.7.1 Client host rejected: cannot find your hostname, [0.1.2.3]
```

I know that I need to set a reverse DNS to a specific domain, for example, IP 0.1.2.3 reverses to domain.com. That would solve the problem for one website.  But how to make it work for the other website, for example domain2.com, when both websites use PHP's sendmail method, and the main IP 0.1.2.3 on the dedicated server?

Thank you!


----------



## SirDice (Mar 20, 2014)

You can't. An IP address can only be resolved to a single hostname. It depends a lot on why the email was rejected, it looks like it just want to reverse resolve the IP address. Regardless of what it resolves to the server may just accept the email.


----------



## BernardoCR (Mar 20, 2014)

SirDice, thanks for your answer.

I don't want resolve an IP address to more than one hostname.
My problem is that PHP mail function uses the main IP of the server (in case, for example, 0.1.2.3), and I have multiple websites using this same server.
First domain is domain1.com, and second is domain2.com.
If I make the IP 0.1.2.3 reverses to domain1.com, the e-mail address I'm sending e-mails gets it (because it will reverse the IP 0.1.2.3 and will check that it reverses to domain1.com).
But when site running under "domain2.com" send an e-mail using PHP mail function, it will use the same IP address (0.1.2.3) when sending the e-mail, and the receiver will see that the IP 0.1.2.3 resolves to domain1, and not to domain2, and will reject my e-mail (this, I think, is used to prevent spammers).
So, this is my problem, and I don't know how to solve that.
Thank you.


----------



## ondra_knezour (Mar 20, 2014)

I think it is not your problem. It is a usual scenario to host many domains on a single mail server. From the excerpt you have provided I would suspect missing FQDN, which means that your mailserver says HELLO 1.2.3.4 instead of HELLO mail.example.com, which is so rude that any sane mailserver should close connection imediatelly, which they in most cases do as you see.

Short checklist:
- Does your SMTP server have hostname set? Is it a FQDN - not only mail, but mail.example.com?
- Does a DNS A record for this hostname exists?


----------



## usdmatt (Mar 20, 2014)

When you configure a server, you give it a hostname, such as myserver.mydomain.com. It only has one hostname. Without any special configuration, Sendmail will use this hostname in its communication. If you telnet to your server on port 25, you should see something like the following (assuming it's running and listening on port 25; It does by default on localhost):


```
220 myserver.mydomain.com ESMTP
```

Assuming your public IP address is 0.1.2.3, the following should be true:

1) myserver.mydomain.com should have an A record that points to 0.1.2.3
2) The reverse DNS for 0.1.2.3 should contain a PTR record "myserver.mydomain.com"

It doesn't matter if your server hosts multiple websites. When Sendmail connects out it should always use your actual server hostname in its conversations.


----------

