Visit the LQ Articles and Editorials section
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 12-11-2006, 07:33 AM   #1
LQ Newbie
Registered: Dec 2006
Location: Australia
Distribution: Fedora Core
Posts: 9

Rep: Reputation: 0
PHP mail not connecting to SMTP server but can connect with telnet

Hi everbody.

I've scoured google for any hint of what I might be doing wrong to no avail!

I have been using the PHP mail() function quite happily for a while but I want to send mail via an SMTP server, either installed on another box or a remote one(eg ISP's server).

I get an error "unable to connect to smtp server etc etc"

The weird thing is that I can connect to which ever smtp server I'm try in the script with telnet so I know that port 25 isn't being blocked by my ISP.

The script I'm using is very simple, using the Pear mail package pretty much like this:

require_once "Mail.php";

$from = "Sandra Sender <>";
$to = "Ramona Recipient <>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

$host = "";
//$port = 25; default 25
$username = "username";
$password = "password";

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

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

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

Is there any other files like hosts or network etc that could affect this?

Maybe I should just start from scratch again?

Any help would be greatly appreciated!!
Old 12-12-2006, 06:51 PM   #2
LQ Newbie
Registered: Dec 2006
Location: Australia
Distribution: Fedora Core
Posts: 9

Original Poster
Rep: Reputation: 0
Anybody.... nobody

Yeah it's a weird one. Everything I found on the net with the same problem basically had their ISP blocking port 25...


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
authentication to SMTP server to avoid telnet sailu_mvn Linux - Software 2 12-20-2005 04:52 AM
Help needed to send mail using a remote smtp server with php s1mpl1c1ty Programming 4 09-19-2005 01:53 AM
Cron mail sending using outside SMTP mail server Utah Linux - Software 6 08-24-2005 08:44 PM
PHP Mail via SMTP newuser455 Programming 2 07-09-2005 11:01 PM
Accessing an SMTP server via TELNET ganninu Linux - Security 14 12-10-2003 03:37 AM

All times are GMT -5. The time now is 09:05 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration