Rev 15488 | Rev 15490 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 15488 | Rev 15489 | ||
---|---|---|---|
Line 1743... | Line 1743... | ||
1743 | The first line ($mailheader) must contain the recipient address. |
1743 | The first line ($mailheader) must contain the recipient address. |
1744 | */ |
1744 | */ |
1745 | void exec_mailto(char *p) |
1745 | void exec_mailto(char *p) |
1746 | { |
1746 | { |
1747 | char *from,*subject,*body,*pp,*charset; |
1747 | char *from,*subject,*body,*pp,*charset; |
1748 | char mail_content |
1748 | char mail_content[MAX_LINELEN+1]; |
1749 | /*int status; |
1749 | /*int status; |
1750 | FILE *mailer;// need stdio.h */ |
1750 | FILE *mailer;// need stdio.h */ |
1751 | 1751 | ||
1752 | if(!trusted_module() || is_class_module) return; |
1752 | if(!trusted_module() || is_class_module) return; |
1753 | - | ||
- | 1753 | // searches for the first occurrence of \n |
|
1754 | from=strchr(p,'\n'); if(from==NULL) return; |
1754 | from=strchr(p,'\n'); if(from==NULL) return; |
- | 1755 | // stops the 'p' string here. |
|
1755 | *from++=0; p=find_word_start(p); |
1756 | *from++=0; p=find_word_start(p); |
1756 | if(*p==0) return; |
1757 | if(*p==0) return; |
- | 1758 | ||
1757 | subject=strchr(from,'\n'); if(subject==NULL) return; |
1759 | subject=strchr(from,'\n'); if(subject==NULL) return; |
- | 1760 | // delimitate the 'from' string. |
|
1758 | *subject++=0; from=find_word_start(from); |
1761 | *subject++=0; from=find_word_start(from); |
1759 | if(*from!=0){ |
- | |
1760 | snprintf(buf,sizeof(buf),"From:%s\n",from); |
- | |
1761 | } |
1762 | |
1762 | body=strchr(subject,'\n'); if(body==NULL) return; |
1763 | body=strchr(subject,'\n'); if(body==NULL) return; |
- | 1764 | // // delimitate the 'subject' string. |
|
1763 | *body++=0; subject=find_word_start(subject); |
1765 | *body++=0; subject=find_word_start(subject); |
- | 1766 | // delimitate the 'body' string. |
|
- | 1767 | body=find_word_start(body); |
|
1764 | 1768 | ||
1765 | for(pp=subject;*pp;pp++) if(*pp=='"' || *pp=='\n') *pp=' '; |
1769 | for(pp=subject;*pp;pp++) if(*pp=='"' || *pp=='\n') *pp=' '; |
1766 | 1770 | ||
1767 | charset=getvar("wims_main_font");if(charset==NULL) charset="windows-1252"; |
1771 | charset=getvar("wims_main_font");if(charset==NULL) charset="windows-1252"; |
1768 | snprintf(mail_content,sizeof(mail_content), |
- | |
1769 | "To:%s\n%sSubject:%s\nContent-Type: text/html;charset=\"%s\"\n\n%s",p,buf,subject,charset,body); |
- | |
1770 | 1772 | ||
- | 1773 | if(*from!=0){ |
|
- | 1774 | snprintf(mail_content,sizeof(mail_content), |
|
- | 1775 | "To:%s\nFrom:%s\nSubject:%s\nContent-Type: text/html;charset=\"%s\"\n\n%s\n",p,from,subject,charset,body); |
|
- | 1776 | } else { |
|
- | 1777 | snprintf(mail_content,sizeof(mail_content), |
|
- | 1778 | "To:%s\nSubject:%s\nContent-Type: text/html;charset=\"%s\"\n\n%s\n",p,subject,charset,body); |
|
- | 1779 | } |
|
1771 | accessfile(mail_content,"w","%s/mail.eml",tmp_dir); |
1780 | accessfile(mail_content,"w","%s/mail.eml",tmp_dir); |
1772 | wrapexec=1; |
1781 | wrapexec=1; |
- | 1782 | // you can add option '-vv' to make sendmail more verbose. |
|
1773 | call_sh("cat %s/mail.eml | /usr/sbin/sendmail - |
1783 | call_sh("cat %s/mail.eml | /usr/sbin/sendmail -t 2> %s/sendmail.log",tmp_dir,tmp_dir); |
1774 | 1784 | ||
1775 | mail_log(p); |
1785 | mail_log(p); |
1776 | *p=0; |
1786 | *p=0; |
1777 | } |
1787 | } |
1778 | 1788 |