-2

I try to send a mail from php via my local smtp server (using PEAR mail). I have a message of success but the message is not send. I think the problem is in my server.. Even when i test with telenet i get no error.. Here is an extract off my php code :

require_once "Mail.php";

$from = "<hotline.cfao@test.com>";
$to = "<pessokho@gmail.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

$host = "10.68.153.137";
$port = "25";

$headers = array ('From' => $from,
  'To' => $to,
  'Subject' => $subject);
$smtp = Mail::factory('smtp',
  array ('host' => $host,
    'port' => $port));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
  echo("<p>" . $mail->getMessage() . "</p>");
 } else {
  echo("<p>Message successfully sent!</p>");
 }

When i call this script i got "Message successfully sent!". When check in my mail box i got nothing.

1 Answers1

0

you have to share more detail about your problem , actually when you see send message success it means your email server do the job but its possible outgoing port in your side or your internet provider (ISP) is blocking the smtp email port

check if the outgoing port is accessible , SMPT 25 :

Type the following command:

telnet example.com 25

View Results:

If Port 25 is not blocked, you will get a successful 220 response (text may vary).

Trying 64.13.192.208...
Connected to example.com.
Escape character is '^]'.
220 example.com ESMTP Exim 4.63 Sat, 07 Sep 2019 20:40:01 -0400

If Port 25 is blocked, you will get a connection error or no response at all.

Trying 150.13.192.200...
telnet: connect to address 150.13.192.200: Connection refused
telnet: Unable to connect to remote host

if its closed ( normaly is closed in 60% of ISP's because of sending spam problem) there is some way to fix it

1- change your isp

2- use another email server as SMTP Relay

3- use VPN

4- use encrypt port 587

ermya
  • 76
  • 3
  • 11