# sendmail:Sender address rejected: Domain not found error

## Shneids

```
sendmail: RCPT TO:<???@???.???> (450 <apache@webserv>: Sender address rejected: Domain not found)
```

I setup a simple php script to test if my Apache2 web server will send an email.  It didn't work, so I looked in the file /var/log/apache2/error_log and I got the above code.  I know senmail is a tough cookie to crack, anyone have any idea of how to solve it.

```
echo 'test' | sendmail ???@???.???

sendmail: RCPT TO:<???@???.???> (450 <root@webserv>: Sender address rejected: Domain not found)

echo 'test' | ssmtp ???@???.???

ssmtp: RCPT TO:<???@???.???> (450 <root@webserv>: Sender address rejected: Domain not found)
```

I tried these, but they didn't work obviously

----------

## flakzeus

I'm thinking your problem is that you do not have a full domain name in your sender address. "<apache@webserv>" should be something like "apache@webserv.com" 

In your php script, make it so you can specify the sender address and set it as "apache@webserv.yourdomain.com" and see if that works.

----------

## Shneids

```
cat /var/www/localhost/htdocs/sendmail.php 

<html>

<head>

<title> Sending mail from the form in Listing 10.10</title>

</head>

<body>

<?php

echo "<p>Thank you, <b>$_POST[name]</b>, for your message!</p>";

echo "<p>Your e-mail address is: <b>$_POST[email]</b>.</p>";

echo "<p>Your message was:<br>";

echo "$_POST[message] </p>";

//start building the mail string

$msg = "Name:    $_POST[name]\n";

$msg .= "E-Mail:  $_POST[email]\n";

$msg .= "Message: $_POST[message]\n";

//set up the mail

$recipient = "mymail@mail.com";

$subject = "Form Submission results";

$mailheaders = "From: My Web Site <blah@blah.com> \n";

$mailheaders .= "Reply-To: $_POST[email]";

//send the mail

mail($recipient, $subject, $msg, $mailheaders);

?>

</body>

</html>
```

Here is the code I currently have, i don't think i have to fix anything here.  Could it be a config file that needs to be fixed?  I've been searching the web for answers, the one thing that keeps showing up is sendmail.mc needs to be configured.

php.ini

```
sendmail_path = /usr/sbin/sendmail -t -i
```

----------

## flakzeus

 *Quote:*   

> If you're using a linux server using Postfix, and your server hasn't the host name set to a valid name (because it's behind a firewall in an intranet), it's possible that when sending mails using the mail function, some mail servers reject them. This is because they can't check the return path header. If you want to change the Return-Path used by sendmail init the php.ini and edit the sendmail_path variable to this:
> 
> sendmail_path = "sendmail -t -i -F webmaster@yoursite.com -f webmaster@yoursite.com"

   Taken from the php.net site

----------

## Shneids

My server is not using Postfix, it's using ssmtp.  The code didn't work btw.

----------

## Shneids

anyone know how to fix this?

----------

