#!/bin/bash


HTML="$1"

BODY=$(cat <<-END
<html>
<head>
<style>
body {
    margin-left: 25px;
}
.row0 {
    font-weight: bold;
}
table, tr, td {
    background-color: AntiqueWhite;
    border-collapse: collapse;
    border: 1px solid white; 
    color: DarkSlateGrey;
}
tr, td {
    padding: 15px;
    text-align: left;
}
</style>
</head>
<body><b>Expected concentration of airborne dust</b>
<br>
<br>
${HTML}
<br>
<br>
<table>
<tr><td style="width: 50px;"><p style="background-color: green; padding: 8px;">&nbsp;</td><td>Normal</td></tr>
<tr><td style="width: 50px;"><p style="background-color: gold; padding: 8px;">&nbsp;</td><td>High</td></tr>
<tr><td style="width: 50px;"><p style="background-color: darkorange; padding: 8px;">&nbsp;</td><td>Very High</td></tr>
<tr><td style="width: 50px;"><p style="background-color: red; padding: 8px;">&nbsp;</td><td>Extremely High</td></tr>
</table>
<br>
<br>
<p>This product has been designed and is generated by the State Meteorological Agency of Spain (AEMET) and the Barcelona Supercomputing Center (BSC) in collaboration with the Burkina Faso National Meteorological Agency. It is released by the WMO SDS-WAS Regional Center for Northern Africa, Middle East and Europe: <a href="https://sds-was.aemet.es/forecast-products/burkina-faso-warning-advisory-system">https://sds-was.aemet.es/forecast-products/burkina-faso-warning-advisory-system</a></p>
<br>
<p>DISCLAIM: The accuracy or reliability of the dust forecasts is not guaranteed and the providers disclaim liability of any kind, including, without limitation, liability for quality, performance and fitness for a particular purpose arising out of the use, or inability to use the forecast.</p>
<br>
</body></html>
END
); BODY=${BODY%a}


MFR="dust@aemet.es"

SBJ="Warning Advisory System for Sand and dust Storm"


MTO="ernest_ok@yahoo.com, koudaogo@yahoo.fr, z_peter4@yahoo.fr, aimsonoued4@yahoo.fr, mamsavadogo@yahoo.fr, lallej@yahoo.fr, guinabf@yahoo.fr, oueder67@yahoo.fr, grebaki@yahoo.fr, michel78us@yahoo.com, ousmanealyyabyoure@gmail.com, sawadogolazare@gmail.com, ouedleon@gmail.com, domezag_dabire@yahoo.fr, dango.alfred@gmail.com, udiasso@gmail.com, Jose Camacho <jcamacho@wmo.int>, Jean-Baptiste Migraine <jbmigraine@wmo.int>, 'Robert Stefanski' <rStefanski@wmo.int>, 'Alexander Baklanov' <abaklanov@wmo.int>, Utchang Kang <UKang@unccd.int>, Nicholas Middleton <nicholas.middleton@st-annes.ox.ac.uk>"

MCC="Sara Basart <sara.basart@bsc.es>, Ernest  Werner <ewernerh@aemet.es>, francesco.benincasa@bsc.es, dust@aemet.es"

BCC="fbeninca@gmail.com"

TID=$(uuidgen)

(
echo "From: $MFR "
echo "To: $MTO "
echo "Cc: $MCC"
echo "Bcc: $BCC"
echo "MIME-Version: 1.0"
echo "Content-Type: multipart/alternative; " 
echo ' boundary="'$TID'/dust.aemet.es"' 
echo "Subject: $SBJ" 
echo "" 
echo "This is a MIME-encapsulated message" 
echo "" 
echo "--$TID/dust.aemet.es" 
echo "Content-Type: text/html" 
echo "" 
echo "$BODY"
) | /usr/sbin/sendmail -t

exit
