You could try to assign the Content-Type explicitly as ' text/plain' of the header fields that is sent via script.
Apparently explicitly denoting the charset and type of the message helps .
Although ,the spam filtering criteria is set by the mailing application , its unclear on what basis a mail falls into spam.
Most of the apps like Gmail have variety of filtering criteria , it decides if the mails are sent to inbox or spam folder.
You could try to assign the
Content-Type explicitly as ' text/plain'
of the header fields that is sent via script. Apparently explicitly denoting the charset and type of the message helps .Source Doc
Note here the subtype="plain"
Although ,the spam filtering criteria is set by the mailing application , its unclear on what basis a mail falls into spam. Most of the apps like Gmail have variety of filtering criteria , it decides if the mails are sent to inbox or spam folder.