creating html email with new html templates email sending fe

Discussion of the Meteohub software package

Moderator: Mattk

Post Reply
wfpost
Platinum Boarder
Platinum Boarder
Posts: 591
Joined: Thu Jun 12, 2008 2:24 pm
Location: HONSOLGEN
Contact:

creating html email with new html templates email sending fe

Post by wfpost »

I tested the new HTML template email sending feature and what I´m getting in my inbox is an email in plain text form. :dry:

Was these feature intended to do something else, or what do I need to do to create a HTML email instead of one with plain text and the html code only included in the mail body?

Anybody knows?

thanks ...
User avatar
admin
Platinum Boarder
Platinum Boarder
Posts: 7879
Joined: Mon Oct 01, 2007 10:51 pm

Re:creating html email with new html templates email sending

Post by admin »

The feature takes a html template, fills it with values and sends this as an email body. So it is not really sending html emails. I have to admit, that I don't really know how a html-email might look like. Is it just a body with html tags in it or does it need additional info outside the body?

However, it is meant to send the selected ".html" file as is (but filled with data).
wfpost
Platinum Boarder
Platinum Boarder
Posts: 591
Joined: Thu Jun 12, 2008 2:24 pm
Location: HONSOLGEN
Contact:

Re:creating html email with new html templates email sending

Post by wfpost »

in order to send a HTML email, the email client needs to know how to process such an email:
http://en.wikipedia.org/wiki/HTML_e-mail

What´s meteohub email program?
sendmail?

dann müsste es so klappen
http://www.perlunity.de/perl/forum/thread_013318.shtml


Community » CGI: Allgemeines Forum zur Themenübersicht Themensuche Themenansicht in Thread-Modus


Beitrag
Kann sendmail auch HTML Mails verschicken
Seitenanfang
Hallo,

ich öffne mit meinem Script eine html Datei und verschickte diese mit sendmail. Leider kommt nur der Code als reiner Code an, und nicht im HTML Format.
Geht das auch anders ?

Gruß Christof

Datum: 18.04.2002-23:47

Beitragre: Kann sendmail auch HTML Mails verschicken
Seitenanfang
Das hat mit sendmail nichts zu tun. Sendmail verschickt nur den Text, denn Du angibst. Damit das als HTML-Mail im Mailprogramm erscheint, musst Du einen entsprechenden Header mitschicken. Das geht sehr einfach mit dem Modul Mime::Lite

use MIME::Lite;
$msg = new MIME::Lite

From => "from\\@server.de",
To => "to\\@server.de",
Subject => "Das ist eine HTML-Mail",
Type => 'text/html',
Data => "<HTML><BODY><H1>HTML MAIL</H1></BODY></HTML>";

$msg->send;

Schau einfach mal in die Modul-Doku, dass ist das noch genau erklärt.

Datum: 19.04.2002-17:25

Beitragre: Kann sendmail auch HTML Mails verschicken
Seitenanfang
oder du schreibst einfach als erste Zeile im MailBody
print MAIL "Content-Type: text/html\\n\\n";

Datum: 19.04.2002-21:53

Beitragre: Kann sendmail auch HTML Mails verschicken
Seitenanfang
Wenn Du HTML-Mails verschicken möchtest, dann beschäftige Dich vorher mit den MIME Formaten. Ich hab da so meine Erfahrungen gemacht.
Am einfachsten schust Du Dir verschiedene Quelltexte von E-Mails an.
Reine HTML-Mails zum Beispiel können nicht alle User lesen, daher sollte zumindest per multipart/alternative der Text im Format plain/text mit gesandt werden.

Datum: 19.04.2002-23:55

Beitragre: Kann sendmail auch HTML Mails verschicken
Seitenanfang
Ich hab bei meinem Space-Anbieter auch ewig rumtesten müssen: Letztendlich hat folgendes geklappt:

print MAIL "From: xyz\\@xyz.com\\n";
print MAIL "To: xyz\\@xyz.net\\n";
print MAIL "Subject: Dies ist ein Test\\n";
print MAIL "Content-Type: text/html; charset=utf-8\\n";
print MAIL "\\n\\n";
print MAIL2 "TestTestTest\\n\\n";

...oder einen anderen charset eintragen
Nur Content-Type: text/html einzutragen hat bei meinem Server nix geholfen, da der Mail-Server sein "plain/text" einfach drübergeknallt hat

Datum: 24.04.2002-09:04
skyewright
Platinum Boarder
Platinum Boarder
Posts: 873
Joined: Fri Jan 25, 2008 6:27 pm
Location: Isle of Skye, Scotland

Re:creating html email with new html templates email sending

Post by skyewright »

admin wrote:However, it is meant to send the selected ".html" file as is (but filled with data).
FWIW, a plain text email constructed that way is exactly what I expected, and am happy with.

I appreciate that some might want html e-mail, but I hope that if implemented it would be optional, with plain text only still possible.
Nimbus43
Senior Boarder
Senior Boarder
Posts: 66
Joined: Mon Jan 28, 2008 4:43 pm
Location: 28865 Lilienthal, Germany

Re:creating html email with new html templates email sending

Post by Nimbus43 »

Hello Boris,

Thanks very much for implementing the e-mail feature. Do you think you can make it possible to send just the weather data without all the html stuff?

Example:

Weather report 200905051600:
Temp: 21,5
Baro: 1031
Wind: 21 km/h (or kts) NNE
Gusts: 34 km/h
Rain: 4,5 mm


Kind regards,

Mario
User avatar
admin
Platinum Boarder
Platinum Boarder
Posts: 7879
Joined: Mon Oct 01, 2007 10:51 pm

Re:creating html email with new html templates email sending

Post by admin »

it sends exactly the data that is in the template file. If you don't put html tags in it, Meteohub will not invent them ;-)

Your Example can be handled by a template file named "minbusexample.html" with this plain text in it:

Code: Select all

Weather report [actual_localdate]
Temp: [actual_th0_temp_c:-]
Baro: [actual_thb0_sealevel_hpa:-]
Wind: [actual_wind0_speed_kmh:-] km/h [actual_wind0_dir_en:-]
Gust: [actual_wind0_gustspeed_kmh:-] km/h
Rain: [day1_rain0_total_mm:-] mm
The ":-" in the variable name takes care that "-" is displayed if the value is not available. Otherwise Meteohub will display the variable name, which looks ugly to my eyes.
Nimbus43
Senior Boarder
Senior Boarder
Posts: 66
Joined: Mon Jan 28, 2008 4:43 pm
Location: 28865 Lilienthal, Germany

Re:creating html email with new html templates email sending

Post by Nimbus43 »

Boris,

OK, great, thank you very much!

Regards,

Mario
User avatar
admin
Platinum Boarder
Platinum Boarder
Posts: 7879
Joined: Mon Oct 01, 2007 10:51 pm

Re:creating html email with new html templates email sending

Post by admin »

btw, someone asked for the mail send program used in meteohub. It is eSMTP, some basic info can be found here: http://blogs.techrepublic.com.com/opensource/?p=232
cbhiii
Gold Boarder
Gold Boarder
Posts: 306
Joined: Fri Feb 15, 2008 2:02 am
Location: Michigan, USA
Contact:

Re:creating html email with new html templates email sending

Post by cbhiii »

Is it possible for the email program in Meteohub to include the following lines in the header when email is sent so that email programs will recognize the HTML and display it properly?


[*]MIME-Version: 1.0
Content-Type: text/html;
charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable
Station: Davis Vantage Pro2 Plus
Hardware: Raspberry Pi 2 (Meteohub status)
wfpost
Platinum Boarder
Platinum Boarder
Posts: 591
Joined: Thu Jun 12, 2008 2:24 pm
Location: HONSOLGEN
Contact:

Re:creating html email with new html templates email sending

Post by wfpost »

admin wrote:btw, someone asked for the mail send program used in meteohub. It is eSMTP, some basic info can be found here: http://blogs.techrepublic.com.com/opensource/?p=232
the docs of eSMTP doesn´t give any hint that html-email is supported.
Also, I was wondering the config file isn´t filled with any user settings.
Looks like a temporary file is used at the very moment email is sent and the config file is returned to its default values.

No html-email possible, even with manual altering of config files? True?
Post Reply