1

I'm trying to send mails from a contact form in a page on my server.

I followed this post.

My PHP file /var/www/my_project/test.php is this:

<?php
$myemail = "[email protected]";
$subject = "my subject";
$message = "my message ";
mail($myemail, $subject, $message);
echo "sent";
?>

If I run the PHP file from the shell:

php /var/www/my_project/test.php

I receive the email in Gmail, then, I'm supposing ssmtp is well configured, right?

But if I run the PHP from the browser:

http://localhost/my_project/test.php

it doesn't send the mail and it creates this file with the email content:

/var/www/dead.letter

I did these steps too:

costales@server:~$ sudo cat /etc/php5/apache2/php.ini | grep sendmail
sendmail_path = /usr/sbin/sendmail -t
costales@server:~$ sudo service apache2 reload

costales@server:~$ telnet smtp.gmail.com 587
Trying 173.194.67.109...
Connected to gmail-smtp-msa.l.google.com.
Escape character is '^]'.
220 mx.google.com ESMTP dm2sm7052263wib.8 - gsmtp

Any idea please? Thanks in advance!

1 Answer 1

2

Is it Drupal? Then you might take a look at this post: https://drupal.org/comment/2032080#comment-2032080

It might have to do with user permissions. Try adding the apache user to /etc/mail/virtusertable and rehashing the /etc/mail/virtusertable.db

Sendmail needs to be configured for it to work with the httpd server user.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .