Using hMailServer to send emails from PHP

Use this forum if you have installed hMailServer and want to ask a question related to a production release of hMailServer. Before posting, please read the troubleshooting guide. A large part of all reported issues are already described in detail here.
Post Reply
Draco18s
New user
New user
Posts: 7
Joined: 2014-05-20 19:02

Using hMailServer to send emails from PHP

Post by Draco18s » 2014-05-20 19:15

First off, I'm not a server guy in the slightest. As far as I've ever been concerned before, email runs on a combination of magic and fairy dust.

All I want to do is set up a box that I have next to me with a bugtracker software, throw it in the basement and go "yay" and then bash my face into the brickwall that is "getting people to use it."

Problem: bugtracker can't send email.

Nothing I've tried has generated an error that I can even go "hey, I got this error, what do I do?" there are no logs generated, no server warnings, nothing. Just a complete lack of emails being sent out (the most I have is Mantis telling me that there was a problem and to check the settings).

I know literally nothing about what I'm doing, half the options I'm given involve things that I know nothing about, and documentation is scattered, incomplete, or written for someone who actually knows WTF they're doing. In trying to research the problem I've been directed at at least three different tools, without any advice as to how to use them, and when it doesn't work I'm back to where I started: knowing jack and all about the problem.

All I want is a localhost email server that sends outgoing email to Verizon's smtp relay server (or Google's, I'm not picky) to a desired address so that when something on the bugtracker changes, it can notify everyone watching it. We do have our own company domain and email server, but installing the bugtracker there has had its own set of problems that are unresolvable,* and I can't use it as the outgoing mail server due to the dynamic IP address we're on in the office (we have to use Verizon's relay server to send email from our own domain anyway). But I don't know what settings I need to give to hMailServer and PHP so that outgoing email works.

*1) it doesn't run PHP and 2) any bugtracker that uses ASPX won't work because of other settings in our server that we can't change without breaking two hosted sites we run for our clients. Basically, the server is held together with spit and bubblegum so when I was offered this unused machine I thought I'd have an easier time.

Bill48105
Developer
Developer
Posts: 6192
Joined: 2010-04-24 23:16
Location: Michigan, USA

Re: Using hMailServer to send emails from PHP

Post by Bill48105 » 2014-05-20 20:31

If it can send via SMTP then you should be able to set it up in 5 min. (OK 30 min n00b time lol)
Assuming it can indeed send via SMTP you download latest 5.4 hmail. Install it using built-in mssql ce database (for your needs it will be fine as long as it's not commercial use). Add a route in hmail to verizon. You set it up just like an email client (tbird, outlook etc). In your tracker set server to localhost or 127.0.0.1. Be sure to put your verizon email or one they allow as the 'from' in your setup. Make sure all logging is setup in hmail & test.
Bill
hMailServer build LIVE on my servers: 5.4-B2014050402
#hmailserver on FreeNode IRC https://webchat.freenode.net/?channels=#hmailserver
*** ABSENT FROM hMail! Those in IRC know how to find me if urgent. ***

Draco18s
New user
New user
Posts: 7
Joined: 2014-05-20 19:02

Re: Using hMailServer to send emails from PHP

Post by Draco18s » 2014-05-20 20:38

Bill48105 wrote:If it can send via SMTP...
And if it can't?

And how do I figure out if it can or not?

Bill48105
Developer
Developer
Posts: 6192
Joined: 2010-04-24 23:16
Location: Michigan, USA

Re: Using hMailServer to send emails from PHP

Post by Bill48105 » 2014-05-20 21:14

hmail can only accept mail via SMTP. Well it can get mail from a script using COM API but that is non-standard. Some scripts rely on sendmail which is only on *nix
hMailServer build LIVE on my servers: 5.4-B2014050402
#hmailserver on FreeNode IRC https://webchat.freenode.net/?channels=#hmailserver
*** ABSENT FROM hMail! Those in IRC know how to find me if urgent. ***

Draco18s
New user
New user
Posts: 7
Joined: 2014-05-20 19:02

Re: Using hMailServer to send emails from PHP

Post by Draco18s » 2014-05-20 22:04

So basically if it can't make it out of the PHP, then hMail won't help me.

Bill48105
Developer
Developer
Posts: 6192
Joined: 2010-04-24 23:16
Location: Michigan, USA

Re: Using hMailServer to send emails from PHP

Post by Bill48105 » 2014-05-20 23:29

Draco18s wrote:So basically if it can't make it out of the PHP, then hMail won't help me.
yes & no. yes in that the script either does mail handling itself or uses php, built-in or some library. By default php tries to use sendmail which windows doesn't support so you need to make sure php and/or your script is setup to use SMTP instead. Once you do then yes hmail will do the trick if setup right.
hMailServer build LIVE on my servers: 5.4-B2014050402
#hmailserver on FreeNode IRC https://webchat.freenode.net/?channels=#hmailserver
*** ABSENT FROM hMail! Those in IRC know how to find me if urgent. ***

Draco18s
New user
New user
Posts: 7
Joined: 2014-05-20 19:02

Re: Using hMailServer to send emails from PHP

Post by Draco18s » 2014-05-20 23:34

Then I need instructions on how to do that.

Hell, I even have a fake sendmail that is set up the way it's supposed to be set up (according to the dozen+ postings on "oh, just use a fake sendmail with these settings") and that doesn't work.

As I said, I have no flipping idea what the problem is, where it lies, or how to diagnose it.

All I know is that I try to send an email through Mantis (which, by the way, has 3 options: PHP_MAIL, PHP_SENDMAIL, and PHP_SMTP) and I get "something went wrong, check your settings." I've tried every setting in Mantis, PHP, and sendmail with exactly identical results:

"Check your settings."

User avatar
mattg
Moderator
Moderator
Posts: 20837
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: Using hMailServer to send emails from PHP

Post by mattg » 2014-05-20 23:41

Use PHP_SMTP

Make sure that it is set up in your PHP.ini

If you can't do that, you probably shouldn't be running a mailserver. It seems counter intuitive to support someone so clueless that their server could become a spambot, when we spend our day fighting SPAM and spammers.

Please make sure that you protect your server so that it doesn't send mass spam...
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

Draco18s
New user
New user
Posts: 7
Joined: 2014-05-20 19:02

Re: Using hMailServer to send emails from PHP

Post by Draco18s » 2014-05-21 00:13

Given that it's only going to be accessible from our internal IP, that won't be a problem. I completely understand the concern over spam.

That's also why I want to use the Verizon relay server, as there's a hard limit on how many emails we can send through it per day for the same reason (100 recipients per email and 500 emails*).

Anyway, as I've said, I've tried using PHP_SMTP and setting the settings. Nothing happens.

Here's the settings in Mantis:

Code: Select all

$g_phpMailer_method		= PHPMAILER_METHOD_SMTP;
$g_smtp_host			= 'smtp.verizon.net';
$g_smtp_username = '******';
$g_smtp_password = '******';
$g_smtp_connection_mode = 'ssl';
$g_smtp_port = 465;
And in PHP.ini:

Code: Select all

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.verizon.net
; http://php.net/smtp-port
smtp_port = 465

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = ****@****.com
And yes, I restart WAMP after changing the PHP.ini file.

And the result:
Image
(email edited out after the error was returned using Firebug)

You see why I'm so frustrated? It should be that simple. Everything I've looked for says it is. Yet, it isn't. And I don't know why and I don't know how to diagnose it. Everyone I talk to either doesn't remember how they did it, has never done it, or scoffs at how easy it is. I'm a front-end programmer, not a sysadmin.

*We actually hit that limit for legitimate purposes for a client project once. And yes, we're are finding a better way to handle their needs. It's not a high priority item as it's a twice-a-year thing.

User avatar
mattg
Moderator
Moderator
Posts: 20837
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: Using hMailServer to send emails from PHP

Post by mattg » 2014-05-21 01:03

Draco18s wrote: Here's the settings in Mantis:

Code: Select all

$g_phpMailer_method		= PHPMAILER_METHOD_SMTP;
$g_smtp_host			= 'smtp.verizon.net';
$g_smtp_username = '******';
$g_smtp_password = '******';
$g_smtp_connection_mode = 'ssl';
$g_smtp_port = 465;
And in PHP.ini:

Code: Select all

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.verizon.net
; http://php.net/smtp-port
smtp_port = 465

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = ****@****.com
These settings point to verizon.net and NOT your hmailserver which is localhost (127.0.0.1), port 25, no SSL
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

Draco18s
New user
New user
Posts: 7
Joined: 2014-05-20 19:02

Re: Using hMailServer to send emails from PHP

Post by Draco18s » 2014-05-21 02:10

That may be, but...
Draco18s wrote:So basically if it can't make it out of the PHP, then hMail won't help me.
...I don't even know if pointing it at hMail is going to make a difference.

And according to replies upthread, it won't, because it's failing somewhere else. Telling PHP to use hMail instead of Verizon isn't going to fix the problem because that's not where the problem is.

Or is it?

How do I find out?

User avatar
mattg
Moderator
Moderator
Posts: 20837
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: Using hMailServer to send emails from PHP

Post by mattg » 2014-05-21 05:34

If you don't use hMailserver in the middle to send, then there is no point in asking us for help...

You should contact either PHP support or Mantis support
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

percepts
Senior user
Senior user
Posts: 5282
Joined: 2009-10-20 16:33
Location: Sceptred Isle

Re: Using hMailServer to send emails from PHP

Post by percepts » 2014-05-21 05:43

well since that error panel you posted says you are using PHPMailer, then you don't need hmailserver to send mail using your verizon account.

All you need to do is work out how to use the software / php / PHPMailer and hmail is completely out of the equation. And that means so is support from here too.

Draco18s
New user
New user
Posts: 7
Joined: 2014-05-20 19:02

Re: Using hMailServer to send emails from PHP

Post by Draco18s » 2014-05-21 06:12

percepts wrote: And that means so is support from here too.
And that's fine. It did answer one question, which was whether or not I even needed it.

You guys may not have solved my problem, but you did narrow down the options.

Thanks

Post Reply