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
Ugly text/plain part #23
Comments
I didn't think anyone else was using plain text in emails. Also pull request welcome :) |
Anyone, who cares about own privacy uses plain text at least as default or even disables HTML at all... I tried two html2text libraries https://github.com/mtibben/html2text and https://github.com/soundasleep/html2text both are able to create plain text results from your HTML like mails, with slightly better results in first library but at cost of XML dependency. Using these libraries will allow to use real HTML, for more compatibility with different clients... |
I am able to get desired output with this: <?php
/** @var string $subject */
/** @var \Illuminate\Support\Collection $items */
/** @var \Fisharebest\Webtrees\Fact $fact */
echo "<h2>$subject</h2>\n\n";
foreach ($items as $group => $facts) :
echo "<h3>$group</h3>\n";
echo "<ul>\n";
foreach ($facts as $fact) :
$record = $fact->record();
echo " <li>" . $fact->label() . ': ';
echo '<a href="' . e($record->url()) . '" style="text-decoration:none;">' . strip_tags($record->fullName()) . "</a> ";
$year = $fact->date()->display(false, '%Y');
if (!empty($year))
echo "(" . strip_tags($year) . " / " . strip_tags($fact->anniv) . ")";
echo "</li>\n";
endforeach;
echo "</ul><hr />\n";
endforeach;
// signature
echo '<p style="color:#444;">-- <br />'."\n";
echo "webtres</p>"; Notice, i changed the HTML slightly, i use unordered list of group's facts (ul), h2/h3 tags for titles and some styles are added. With this i got plain text:
At end i add signature placeholder. IMO, here have to be info about unsubscribe, or at least link to webtrees, but i do not know how to get this URL. I will suggest to add List-ID and List-Unsibscribe headers too, but i will create separate issue for this latter. |
List-ID and List-Unsibscribe is webtrees issue. Modules can't attach this headers. |
Not really ;-) only its send method is not suitable for purpose of this module. Because its transport method (thus mail settings) is reusable, it seems to be simple to implement... I will try it latter as i recently did little play with SwitMailer, but my PHP knowledge are (very) limited (e.g. no OOP), it will need to be polished... |
@slavkoja try latest master version. Seems plain text message looks fine now. |
I will try soon. But are you sure, that it is better to fix ugly HTML by calling four functions (including expensive regexp) instead of fixing HTML and stay on one function call? |
No ;) |
Do you want to help with HTML? |
You can use own html if you wish. For me prefer more readable variant without closing tags far away from opened :) |
Hi, the text/plain part of email is constructed via strip_tags, which is not bad at all, but this preserves all whitespaces and line ends, which results terrible readable text part:
This can be solved by some external library, which can be overkill. More simplest way can be to format the HTML to not have useless white spaces and line ends, for now, the HTML part (only related part)look as this:
The text was updated successfully, but these errors were encountered: