<empty> from address php mail()

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
jwadew
Normal user
Normal user
Posts: 45
Joined: 2006-06-13 02:52

<empty> from address php mail()

Post by jwadew » 2019-08-06 05:43

I am replying to the same email from two sources, using the same from address:

1. From Outlook - everything is fine. The from address shows correctly both as received from outlook to hMail:
"SMTPD" 4192 50072 "2019-08-05 22:28:53.905" "99.60.0.84" "RECEIVED: MAIL FROM: <someone@domain.com>"
and when hMail sends:
"APPLICATION" 5476 "2019-08-05 22:28:54.280" "SMTPDeliverer - Message 5575840: Delivering message from SOMEONE@DOMAIN.COM to hy23syfe76mone6ujmu5kjuamx4a7bjbwiuqnafdxqgjp4qdbubsmavh5zueaduv@im.agni.xyzxyzxyz.com. File: C:\Program Files (x86)\hMailServer\Data\{A130162D-DE58-44AF-8B9A-EE198E6DCEC5}.eml"

2. From PHP using mail() - shows correctly as received from outlook to hMail:
"SMTPD" 4192 50280 "2019-08-05 22:20:02.222" "127.0.0.1" "RECEIVED: MAIL FROM:<someone@domain.com>"
But shows empty when hMail sends:
"APPLICATION" 5476 "2019-08-05 22:20:02.924" "SMTPDeliverer - Message 5575786: Delivering message from <Empty> to HY23SYFE76MONE6UJMU5KJUAMX4A7BJBWIUQNAFDXQGJP4QDBUBSMAVH5ZUEADUV@IM.AGNI.XYZXYZXYZ.COM. File: C:\Program Files (x86)\hMailServer\Data\{7FB6E7C7-96D1-4E2C-A04E-66B2FE469318}.eml"

The receiving server ignores any emails received with empty from address, so this is a problem.
Any clues as to why hMail empties the from address here?

There is one other difference. Outlook authenticates, but PHP mail() does not. I am not suspecting a problem there because hMail does not throw an error - I have turned off "Require SMTP authentication" for "Local to external e-mail addresses".

User avatar
jim.bus
Senior user
Senior user
Posts: 253
Joined: 2011-05-28 11:49
Location: US

Re: <empty> from address php mail()

Post by jim.bus » 2019-08-06 10:21

I do not know PHP Mail but googled PHP Mail and received some instructions on commands. So I decided to make some guesses on what went wrong.

Based on the small amount of Log Entries you showed, I believe PHP Mail did not supply the From Header information in the From Header of the Reply. I suspect you supplied the Reply To Header information but did not supply the From Header Information in the Reply email. Your From Header information for the Reply should contain the original Sender's From Header Information contained in the original From Header.

I suggest you look at your original sending PHP Mail email and check to make sure you supplied the From Header information both when sending out the email and supplied the correct From Header information information for the Return (Reply). I suspect you either did not supply the From Header for the Reply or you had a format problem when you set up the Reply From Header. I also saw some references to possible reply problems with such things as supplying multiple Line Feeds (LF) and possibly other control characters improperly embedded in the message or PHP Mail emails.

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

Re: <empty> from address php mail()

Post by mattg » 2019-08-06 11:05

jwadew wrote:
2019-08-06 05:43
Any clues as to why hMail empties the from address here?
hMailserver doesn't empty any fields
jwadew wrote:
2019-08-06 05:43
There is one other difference. Outlook authenticates, but PHP mail() does not. I am not suspecting a problem there because hMail does not throw an error - I have turned off "Require SMTP authentication" for "Local to external e-mail addresses".
The SMTP logs in hMailserver use the SMTP envelope FROM, not the header
The SMTP Envelope from comes from the AUTH in the SMTP conversation
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

jwadew
Normal user
Normal user
Posts: 45
Joined: 2006-06-13 02:52

Re: <empty> from address php mail()

Post by jwadew » 2019-08-06 17:04

Thank you both for your comments.

I did confirm by sending to another of my email addresses that without authentication, even though the hMailServer logs show from <empty>, the from address does come through - as mattg points out.

I have used PHP mail() for years with no problems before, so I am not suspicious of a general format problem or leaving out of any header info.

Unfortunately, the intended recipient is an automated process at a host where there are millions of accounts that are not revenue generators - so very unlikely I could get them to chase anything down for me. There is some difference between sending with Outlook with authentication and sending with PHP mail() without authentication. And that difference, which I cannot seem to discover, is causing this recipient to ignore the emails.

palinka
Senior user
Senior user
Posts: 986
Joined: 2017-09-12 17:57

Re: <empty> from address php mail()

Post by palinka » 2019-08-06 18:08

Why not just add the header to your script and/or authenticate?

$header = "From: $name <$email>\r\n";

jwadew
Normal user
Normal user
Posts: 45
Joined: 2006-06-13 02:52

Re: <empty> from address php mail()

Post by jwadew » 2019-08-06 21:01

palinka, I've tried that, and every combination I could think of.

However, by comparing outgoing headers, the one difference I've been able to find is that when Outlook sends the email (with SMTP authentication), hMailServer will send:
To: name <address>

When the email is sent via PHP mail() (without authentication), hMailServer only sends the address, not the name:
To: address

And this is, no matter what combination of quotes, double quotes, angle brackets, etc I have tried. hMailServer will ignore the NAME on the TO line, in this instance, which I assume will be different if I install something that uses authentication.

I suspect the receiving system requires the NAME in the TO line to match their db in order to act upon it.

jwadew
Normal user
Normal user
Posts: 45
Joined: 2006-06-13 02:52

Re: <empty> from address php mail()

Post by jwadew » 2019-08-06 21:06

...... or it could also be that no matter what I do, PHP mail() is the one stripping off the NAME from the TO line.

palinka
Senior user
Senior user
Posts: 986
Joined: 2017-09-12 17:57

Re: <empty> from address php mail()

Post by palinka » 2019-08-07 00:29

Maybe try this: https://github.com/PHPMailer/PHPMailer

I need to do this too. I have a forgotten about mall form that i broke when i changed hmailserver settings to require authentication on localhost.

Or if you want to roll your own, I'm sure you could integrate blat.exe into a php cmd line.

jwadew
Normal user
Normal user
Posts: 45
Joined: 2006-06-13 02:52

Re: <empty> from address php mail()

Post by jwadew » 2019-08-07 03:39

Palinka, what this turned out to be (I think) is that hMailServer does not format the TO line the same when authenticating as when not authenticating. I spent many hours trying everything possible, but in the end I could not get the combination of PHP mail() and hMailServer to deliver what I needed.

This is not to say hMailServer is at fault, because it is an excellent product. I just couldn't get what I needed with that combination and not having debug ability at the recipient.

I was resisting installing yet another package: PHPmailer, but once I did, I found it to be very easy to set up and it works great!.

Problem solved :)
Thanks to all who commented.

palinka
Senior user
Senior user
Posts: 986
Joined: 2017-09-12 17:57

Re: <empty> from address php mail()

Post by palinka » 2019-08-08 17:25

Cool. Thanks for the update. I haven't had time to mess with it, but I'm kind of interested in the blat.exe idea from a proof of concept angle. Should be pretty simple. If i get it working I'll post the mailer php here.

Post Reply