phpscript work with Hmail?

Use this forum if you have problems with a hMailServer script, such as hMailServer WebAdmin or code in an event handler.
Post Reply
User avatar
Heeter
Normal user
Normal user
Posts: 172
Joined: 2005-11-05 11:51

phpscript work with Hmail?

Post by Heeter » 2007-12-06 23:20

Hi all,

I got this great little php script that does online invoicing for my clients.

I do have a small situation with it, it seems that I cannot email out to my clients with a certain ISP email address (telus.net)

I can email them to the same addresses with my squirrelmail/hmail setup, but not through this phpscript. This script does work when it emails out to other domain email addresses so far.

Is there anyway that I can get a phpscript to use my squirrel/hmail setup to mail out?

My webserver and my emailserver are in the same Server Tower. (Apache/Hmail/MySQL/Windowsserver2003)


Thanks,

Heeter

User avatar
danny6167
Senior user
Senior user
Posts: 472
Joined: 2007-02-07 15:24
Location: Western Australia
Contact:

Post by danny6167 » 2007-12-07 13:17

is the php script actually set to relay through hmail or it sending directly to the reciptant email server.

Is it using mail() ?

send enable smtp logging and get your invoice system to send out a email to that ISP and post the log file here.

User avatar
Heeter
Normal user
Normal user
Posts: 172
Joined: 2005-11-05 11:51

Post by Heeter » 2007-12-08 23:07

Hi Danny,

I started the logging for hmail, nothing got recorded when I emailed the clients with that domain.

Here is the php for the send mail:

Code: Select all

<?

include "inc/config.php";
	$extra = "From: $youremail\r\n";
	$recipient = "$clientemail";
	$subject = "From $yourcompany - invoice notification.";
	
	mail ($recipient, $subject, $message, $extra);
	
?>
Thanks for the help

Heeter

User avatar
martin
Developer
Developer
Posts: 6834
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Post by martin » 2007-12-08 23:12

If nothing at all got recorded, then PHP isn't even trying to connect to hMailServer. Have you checked that the SMTP server name in php.ini is correct?

User avatar
Heeter
Normal user
Normal user
Posts: 172
Joined: 2005-11-05 11:51

Post by Heeter » 2007-12-09 00:42

The smtp server in the php.ini is the smtp from my ISP.

Should I put something else in there?


Heeter

User avatar
martin
Developer
Developer
Posts: 6834
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Post by martin » 2007-12-09 00:45

If you want your PHP script to use hMailServer for sendouts, you should enter hMailServers IP address in php.ini and then restart your web server. If you enter your ISP's email server, outgoing email will be sent via their server.

User avatar
Heeter
Normal user
Normal user
Posts: 172
Joined: 2005-11-05 11:51

Post by Heeter » 2007-12-09 01:03

Do I still use an IP if everything is in the same tower?

Can I use "localhost" instead?


Thanks a million, Martin.


Heeter

User avatar
martin
Developer
Developer
Posts: 6834
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Post by martin » 2007-12-09 01:04

Yes, you can use localhost.

User avatar
Heeter
Normal user
Normal user
Posts: 172
Joined: 2005-11-05 11:51

Post by Heeter » 2007-12-09 01:06

Great, thanks again, Martin



Heeter

User avatar
daniel
New user
New user
Posts: 11
Joined: 2007-08-18 02:56

Post by daniel » 2007-12-14 21:40

Heres another way to do it, as im a webdeveloper i stopped using mail() along time ago as its always not configured right on every webhost out there and when you do sites its to much hassle to try fixing it.

Download Mail.rar and put in the same folder as your index.php or default.php or whatever you name it, this rar was included in the dev package of php 4 once upona time but was removed for some reason, i still use it in my projects today with php5 and it works great.

http://dev.praxxa.com/Mail.rar

Then simply put this at the top of your index.php (or whereever your going to mail)

Code: Select all

include("Mail.php");
The function to use with this is:

Code: Select all

function mejla($to, $title, $by, $body) {
	global $mejl_ip, $mejl_port, $mejl_auth, $mejl_username, $mejl_password;
	$recipients = $to;
	$headers["Date"] = date("D").", ".date("d")." ".date("M")." ".date("Y")." ".date("H").":".date("i").":".date("s")." ".date("O");
	$headers["From"] = "YourFriend <".$by.">";
	$headers["To"] = $to;
	$headers["Subject"] = $title;
	$headers["Content-Type"] = "text/plain; charset=\"iso-8859-1\"";
	$params["host"] = $mejl_ip;
	$params["port"] = $mejl_port;
	$params["auth"] = $mejl_auth;
	$params["username"] = $mejl_username;
	$params["password"] = $mejl_password;
	$mail_object =& Mail::factory("smtp", $params);
	$mail_object->send($recipients, $headers, $body);
}
Now your simply allowed to use any smtp server that you want, as long as your ISP arent blocking the port.

Specify these somewhere in the top of index.php or if you got a config.php or wherever is suited

Code: Select all

$mejl_ip = "192.168.1.1";
$mejl_port = 25;
$mejl_auth = false;  //true for username/password use
$mejl_username = "";
$mejl_password = "";

Post Reply