little tips and tricks, which i stumbled upon randomly

Wednesday, August 15, 2012

HTML mail from SybaseIQ- Sendmail linelength problem (weird ! character)

One of the best ways to send HTML mail from SybaseIQ on IBM AIX is to use sendmail.
Unfortunately sendmail has linelength limit (2040 characters default). After 2040th character sendmail is adding ! and new line characters to text which is ruining HTML.

To fix this problem:
  1. Change Linelimit info in Sendmail.cf file. Add L=4096 (or any other suitable value) to corresponding mailer.
  2. To identify correct mailer check mail log at /var/log/maillog file. Mailer name is mostly Mrelay
  3. After these steps ! character shall be removed from your mail.
  4. You may add ||  CHAR(13) || CHAR(10) after each </tr> statement to add new line in SQL as well.
Sample script which sends HTML mail from Sybase IQ is below
execute immediate 'exec xp_cmdshell ''(echo "From: myadreess@mail.com."; echo "To: dest1@mail.com,dest2@mail.com"; echo "MIME-Version: 1.0";echo "Content-Type: text/html"; echo "<html><body bgcolor=black><blockquote><font color=green>GREEN</font> <font color=white>WHITE</font> <font color=red>RED</font><font color=blue>Powered by Sybase IQ</font></blockquote></body></html>") | sendmail -t''';