# Mail problem

## gouranga

I want to send mail from a php script so I use 

```

<?php

$to = "someone@mail.com";

$subject = "hey";

$body = "text";

 if mail($to,$subject,$body){

     echo "sent";

}

?>

```

The mail is sent, but never received. The php function only checks if the mail is delivered in /var/mail/spool/

So I checked php.ini  in /etc/apache/conf/php.ini

and sendmail path is not filled in.

So what do i need to get this mail function working in php?

I only need to send mail , not to receive.

Thx in advance

gouranga

----------

## adaptr

You need an MTA.

The simplest one is ssmtp, which can only forward mail to a real mail server.

If you have access to one, and do not need local mail services, emerge ssmtp and configure it.

This will take care of the sendmail stuff.

----------

## gouranga

I configured ssmtp.

```

echo test | ssmtp -auUSERNAME-apPASSWORD -s test someone@mail.net

```

ssmtp: Server didn't accept AUTH LOGIN (503 AUTH command used when not advtised)

I used the mail server of my ISP, normaly I can relay on that even without providing a username and password.

What shall I try now?

----------

## DaveArb

You told ssmtp to use authentication (-au, -ap). The error, and you, say that AUTH is not advertised or needed. What happens if you leave off those options?

Dave

----------

## gouranga

when I leave the authentication i get the following error:

ssmtp: RCPT TO:< someone@gmail.com> (550 Sender verify failed)

----------

## DaveArb

What happens if you telnet to their mailserver?

```
telnet <your.ISPs.mailserver.IP> 25

<their greeting>

EHLO <your.domain>

<their advertised list of capabilities>

QUIT
```

They might require an authorization scheme that ssmtp cannot provice. I don't understand why it would allow you to relay some times without username or password, and other times require sender verification. I suspect you're always authenticating, but just don't realize it?

Dave

----------

## adaptr

"sender verification" is not the same as authentication - one can verify a sender in different ways.

The most often used is to reverse-resolve the DNS for the connecting mail server, and see if it resolves to the same domain as it originally gave in the HELO.

Since there is no reason for any mail server to lie about this, mismatched HELO/DNS names are often a good clue about spam senders, and many MTA's will in fact refuse to send mail on behalf of a From: address that is not in a domain known to them.

You need to set a proper From: address with ssmtp.

----------

## gouranga

Ok, root can send e-mails.

I now also configured /etc/ssmtp/revaliases

How can I make the sstmp command availiable for other users ?

Btw, thx for the quick responses. Your help is realy great.

----------

## magic919

Make sure it is in their path and has correct permissions for them to execute.

----------

## gouranga

Ok, the problem is solved.

Although when the mail is received by gmail the From adress is incomplete.

The entry in /etc/ssmtp/revaliases is :

gouranga:noreply@gouranga.dyndns.org:mail.tiscali.be

When received by gmail the from adress :

From: @gouranga.dyndns.org <@gouranga.dyndns.org>

But its working fine when apache sends the email.

So i can send mails with php now.

Thx

----------

