0

I recently installed mail into my php, I can send mail when I do it on my command server but when I use it on php, I dont receive an email

<?php 
error_reporting(E_ALL);
ini_set('display_errors', 1);
require "connection.php";
$email = $_POST['email'];

if(isset($_POST['submit']))
{

$check = mysqli_query($conn, "select * from users where email = '$email' ");
$row = mysqli_fetch_array($check);

$message ="Please click here to create a new password www.jasmine.com/id?=" . $row['id'];
$subject = 'Change password';
$body = "E-Mail: $email\n Message:\n $message";

if($row)
{

    $res = mail ($email, $subject, $body);
    var_dump($res);die;
    echo "Please check your email";
}
}
else
{
echo  "Email Not Found";
}
?>

I researched all over this website, but I found nothing to help me I tried 1) to see if port 25 was blocked, it was not. 2) I tried this code to see if anything would send :

<?php
mail('youremailaddress@here.com','Test Email','Testing to see if this comes through');?>

Nope it didnt 3)when I do telnet domain.com 25 I just get

Trying IP...

telnet: connect to address IP: Connection refused )

[root]# netstat -plnt |grep :25
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1228/master
tcp6       0      0 ::1:25                  :::*                    LISTEN      1228/master

Is there anything else I could do to actually get it working, I installed mail by using the steps on this website, and it should have all worked fine http://www.tecmint.com/setup-postfix-mail-server-smtp-using-null-client-on-centos/

hiba
  • 43
  • 7
  • Oh and it echos out with the var_dump bool(false), without it it echos out please check your email – hiba Dec 13 '16 at 15:19
  • See http://stackoverflow.com/questions/24644436/php-mail-form-doesnt-complete-sending-e-mail/24644450#24644450 for more troubleshooting steps – John Conde Dec 13 '16 at 15:21
  • I saw these and still nothing worked @JohnConde I dont know whats wrong – hiba Dec 13 '16 at 15:23
  • Should be noted that the `mail()` function will use `sendmail` which needs to be correctly configured on the server you are using. If you host through bluehost or 1and1 they usually have sendmail configured. But if you are configuring the server yourself (installing the webserver, php, etc) then you usually have to setup sendmail yourself. The easier way would be to just get a mail server and use smtp. If you are sending less than 100k emails a month then I recommend https://www.sparkpost.com/pricing/ – Skylord123 Dec 13 '16 at 15:43

1 Answers1

0

If you can send mail manually, mail server is ok. It seems that something wrong with php mail - on default, it uses sendmail.

You can try remove postfix and install sendmail (remember to stop/kill postfix services!).

lukasamd
  • 441
  • 1
  • 4
  • 16
  • When I tried installing it I got:Loaded plugins: amazon-id, rhui-lb, search-disabled-repos Could not contact CDS load balancer rhui2-cds01.us-east-1.aws.ce.redhat.com, trying others. Could not contact any CDS load balancers: rhui2-cds01.us-east-1.aws.ce.redhat.com, rhui2-cds02.us-east-1.aws.ce.redhat.com. – hiba Dec 13 '16 at 15:31