I am running the cron job where there is html formatted output. I want to send that output my email address in html format.
Is there any way to do that
php /home/bla/bla_bla.php | mail -s "Bla Bla" -s "bla@bla.com"
-
Add a Content-Type header such as
-a 'Content-Type: text/html; charset="iso-8859-1"'or use a mail client that guesses the Content-Type (GNU mailutils for example probably do that).Master : How can i add content type in command line like above caseal : Depends on the `mail` implementation you're using. BSD mail: `-a`, sendmail: `(echo -e "Header: Value\n"; php bla_bla.php) | mail …`. Just look it up in the man page.From al -
You might want to take a look at mime-construct. It's handy for just this kind of thing. I use it to send a generated HTML doc as part of a daily cronjob like so:
/usr/bin/mime-construct --to "foo@bar.com" --subject "My daily html foo" --multipart multipart/alternative --type text/html --file htmlfiletosend.htmlIf you don't care about the messages being multipart, you can drop that portion. It can also take the html via stdin like so:
php your_script.php | mime-construct --to "foo@bar.com" --subject "Foo Report" --type text/html --file -I don't know what distro you're using, but this is available in the main repositories for Debian and Ubuntu, I would imagine RHEL and derivatives likely have it too.
Master : that looks goodFrom mark
0 comments:
Post a Comment