CI_Email::from() ignores the display name in the email address |
When specifying an email address that contains a display name the from() method in the Email class ignores that display name.
The following example code illustrates my point: PHP Code: $email_address = "Name of Sender <[email protected]>"; The recipient then receives an email that looks something like this: Code: From: [email protected] My work around is to parse the email address and look for a display name in the event that one is not provided, as follows: PHP Code: // Line 483 - 486 in the Email class: I have changed to: PHP Code: if (preg_match('/\<(.*)\>/', $from, $match)) The resulting message then correctly reflects the sender's email address and display name, as follows: Code: From: Name of Sender <[email protected]> I hope this helps someone as the administrators don't feel that it is useful enough to be incorporated in the Email class. Please Note I am aware that there is an additional parameter in the CI_Email::from() method that allows you to specify a display name but then you would have to parse and interrogate the email address before invoking the method in order to separate the email address and the display name which you must then submit as two separate parameters. This would be a lot of unnecessary coding on your part and my solution handles this for you as part of the class method. |
Messages In This Thread |
CI_Email::from() ignores the display name in the email address - by daveherman - 10-18-2017, 04:39 AM
RE: CI_Email::from() ignores the display name in the email address - by InsiteFX - 10-19-2017, 03:22 AM
RE: CI_Email::from() ignores the display name in the email address - by daveherman - 10-23-2017, 05:56 AM
RE: CI_Email::from() ignores the display name in the email address - by InsiteFX - 10-23-2017, 08:36 AM
|