-
-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove header name from ->getHeader()
#123
Comments
I disagree with this one, although there may be less use for a user looking at the entire header, the object itself doesn't care that you called It's also used when writing out an email, essentially the "string" representation of a Message is all the headers and body... I don't assume that because you're looking at a Message you know that the Subject is X, that you're only interested in the text content, etc..., etc..., I'm assuming __toString should give the "string" representation of whatever object it is you're looking at. This may not be consistent in every project, etc... but I think it makes the most sense. If you only want a specific part of it, you'd call $message->getTextContent or $header->getSomethingSpecific, etc.... |
I see what you mean by "string representation of the object". However, if I have a return $this->getFirstName() . $this->getLastName(); not like this: return 'Person: ' . $this->getFirstName() . $this->getLastName();
But there just is no function that gives me the entire header without the name-prefix! (That's what I'm saying) Or is it? |
Yes, but this is not an "Address" entity, it's an "AddressHeader" entity, this makes sense to me. You can echo $message; and get the whole message (which internally calls __toString() on each header, so you can change headers and the whole message will get written out cleanly for example), and it's also not returning "Address: user [email protected]" it's returning "From: user [email protected]", From being the name of the AddressHeader itself. It certainly wouldn't make sense to put "Person: " in front of some random Person object's "__toString", but if it were PersonHeader as part of a mime object, the name of which is "Person", then I think it would 😄 In another ticket I proposed maybe |
Since you mentioned this repeatedly: Is there a use-case for this? I mean, this is an email parser, not an email creator. So if I want to see the entire message, I can take a look at what I passed into |
Yeah, you can modify a parsed email (add attachments/parts, etc..., change content, whatever you want) and do what you will with it after. It's a bit simplistic in that you have to do all the header formatting and such yourself, but yes, it's used. I don't think anyone's using this to create a fresh mime message though... |
But you can't send it? Or can you? |
There's nothing in zbateson/mail-mime-parser to help with sending emails. |
I still think that the
...doesn't convince me since the very sense of an email parser is to look at single parts/headers, not at the entire message. However, I'm closing this in favor of #122, since changing the current behavior only makes sense as part of a larger overhaul of the nomenclature, which we're discussing there. |
Is there a limit for issues per day? ;-)
I think that the main function for reading a header (i.e.
->getHeader()
) should return just the value/content, not the header name:If this is in the email
->getHeader('from')
now returns (seeAbstractHeader::__toString()
):but should return:
Why?
From:
is not part of the informationFrom
header, there's no need to prefix the answer with something like "Here comes theFrom
header". And if I store it in a database (in a column probably calledfrom
), there's no need to store "From:" over and over.I think it's a good idea to do have a function that returns the full line, it just shouldn't be the "main" function. Maybe something like
getFullHeader()
? Speaking of naming: What was your idea behind->getHeaderValue()
? For e.g. theSubject
this would be what I'm asking for here, but forFrom
it just returns the email address, not the person's name.And I spotted a (somewhat related) inconsistency in
README.md
:getPersonName()
vs.getName()
:The former is a method of
AddressHeader
. But since the latter is a method of the more genericParameterPart
, you probably cannot change it in the code?The text was updated successfully, but these errors were encountered: