Write CGI about Sendmail
On the UNIX host, we can easily send email by programming, sometimes we need to send the data from the form to a mailbox, such as a visitor's message, online application.
In the UNIX system, there will be a sendmail program to send email, which is a very complex email system, but we use it in CGI programming to send email is very simple, and the specific operation is to open a channel. The information of the output as a sendmail is as follows: Open (Mail, "| | / usr / sbin / sendsendmail zjxyz@xxxx.xxx"); # Note the space between me, Print Mail $ MSG Close Mail; so we can put Variable $ MSG The content sent to the sendmail program on the server to the address of Zjxyz@xxxx.xxx, pay attention to this is just a simple example, and some details are required to be discussed. In the above program, the recipient of the message will receive a letter without a title, no reply address, to send the letter to the letter, you must send the letter before sending content: Open: Open (Mail, "| | / usr / sbin / sendsendmail zjxyz@xxxx.xxx"); Print Mail "to: $ TOEMAILN"; Print Mail "from: $ offmailn"; Print Mail "Reply-to: $ offmailn"; Print Mail "Subject: $ Subjectn"; PrintMail $ MSG; Print Mail "NN"; Close Mail; "To:", "To:", "From:", "reply-to:", "Subject:" is used to mark Head, they will not be treated as the body of the letter in the process of processing, and the wrap symbol in the program is required. Here, you have to mention the security problem, sometimes the address we send is obtained from the form. If you do not strictly check the legality of the Email address obtained from the form, you will bring an opportunity to attack the malicious attacker. Let your CGI program perform some operations of destroying systems, and consequences are very serious. Simple Example Description: IF ($ form {'mailto'} = ~ / (. *) @ (. *) /) {. . . . . . . . . . . . . . . }