Send Text with PHP, Port 25 block issue – PHP

  php

Q(Question):

After a 2 day stalemate, I seek help!
I use WindowsXP. I live in Canada and my ISP is SaskTel. Through telnet command, it showed that they do block port 25.

I am doing a microcontroller project, that connects to a laptop, and I want to send a text when something happens.

PHP file:

<html>
<body>
<?PHP
//SUBJECT AND BODY OF EMAIL SHOULD BE LESS THAN 160 CHARACTERS TOTAL
$subject = "Text Message Subject";
$message = "Text Message Content";
//SENDS TEXT MESSAGE TO 509-863-4212
mail("5098624212@sms.sasktel.com",$subject,$message,"From: email@site.net");
?>
</body>
</html>

****

I know the email is right, as i sent a text to my phone from my hotmail account.

I do not understand webservers well.. currently I am using "EasyPHP", and have my .php file in a directory, and using the path

http://localhost/test/sendtext.php

I get an error saying "mail function isnt working with port 25, check your SMTP …"

I have read many forums, and they all say that my ISP has it blocked. I also searched long and hard for how to get around this issue. Is it actually possible? Changing ISP is not an option. Can someone point me in a good direction with some handy tips? Anything, I am very exhausted at this point

Thank you,

John

A(Answer):

Your trying to send from your own machine and you do not have a mail server running on it hence the reason port 25 is shut.

Do you have an account anywhere you POP/SMTP? If so you can use PHPMailer to send via that mail server.

A(Answer):

@hoopy

Thanks for reply

No i do not. Can i make an account somewhere?

A(Answer):

Do you not have an email account with your ISP? PHPMailer would allow you to configure your username/pass so you can auth through their mail server and send the email.

I guess you can either run your own mail server or try or find someone who will allow you to send mail through their server via POP before SMTP. You could also look for a free web PHP host who allow email to be sent as well and use that as a 3rd party to send the mails from.

A(Answer):

Okay.

I called my ISP, and we set up an email account. He gave me the information on the smtp name, and a user name and pass. He also said that port 587 is open for me. Does this change anything?

My php file now look like:


<html>
<body>
<?php
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // send via SMTP
$mail->Host = "smtp.sasktel.net"; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "joh"; // SMTP username
$mail->Password = "abc"; // SMTP password
$mail->From = "johash@sastel.net";
$mail->FromName = "John";
$mail->AddAddress("3065418450@sms.sastel.com","Waste");
$mail->AddReplyTo("johnhas@sastel.net","Your Name");
$mail->WordWrap = 50; // set word wrap
$mail->IsHTML(true); // send as HTML
$mail->Subject = "Here is the subject";
$mail->Body = "This is the HTML body";
$mail->AltBody = "This is the text-only body";
if(!$mail->Send())
{
echo "Message was not sent";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
?>
</body>
</html>

Using the PHPMailer class.

I still get the same port error. Is there a step i am missing? At what point am i "connecting to the mail server"

A(Answer):

PHPMailer is old and out of date. Check out SwiftMailer.

Also, please use [code] tags when posting code. [code] … [/code].

Thank you,

Markus.

A(Answer):

@swightness

since port 587 is not the standard port for smtp, you need to tell SwiftMailer (or any mailer class used) that you want to connect using this port.

LEAVE A COMMENT