Link to home
Start Free TrialLog in
Avatar of Jazzy 1012
Jazzy 1012

asked on

Why isnt it sending mail from my php but is from my server

I have this code:

<?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";
}
?>

Open in new window


I get no error, I get please check your mail as an output, however I recieve nothing on my email. But when I try it from my server and send it like this:

# mutt -s "Part 9-RHCE series" tecmint@mydomain.com < mailbody.txt

It sends to my email, but when I do it on php it doesnt, does anyone know what the issue is?
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Could be a lot of things - does your ISP allow sending of mail using mail() from your scripts?

Sometimes you are required to setup an SMTP connection with authentication - it varies from one ISP to the next.

Does this work

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

Open in new window


If that does not work then you need to investigate with your ISP as to why not.

You might also be running foul of SPAM filters - that might be seeing your email as SPAM.

Issues with email are usually outside the script that creates them. There is a lengthy process involved in ensuring your the emails your server sends out are not going to run into any of the speed bumps that are related to sending email from withing scripts on servers.
Avatar of Jazzy 1012
Jazzy 1012

ASKER

The code you gave me didnt work, and nothing is in my junk mail, how do I know what to check in my ISP exactly ?
Just ask them what their policy is with respect to sending email from PHP scripts.
when I do telnet domain.com 25
I just get

Trying IP...




telnet: connect to address IP: Connection timed out
what does this mean
Ok so my ISP isnt blocked, what other issue could there be? and how could i fix it, I used this website to set up mail
http://www.tecmint.com/setup-postfix-mail-server-smtp-using-null-client-on-centos/
[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
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
So I should change my tags?
So I should change my tags?
Better to open a new question - more likely to get a response - you can refer to this question if needs be.