Sending mail (2)

Try online Examples

Extrapolating on the previous example, we will now see how to retrieve the data from multiple 'select' fields.

The message would be sent to nirvana@aptilis.com

Here's what the HTML looks like:

	<FORM ACTION="/cgi-bin/aptilis.exe" METHOD="POST">
	<INPUT TYPE="hidden" NAME="file" VALUE="/home/scripts/sender2.e.txt" />

	Your e-mail address:<BR />
	<INPUT TYPE="text" NAME="from" SIZE="40" /><BR />
	<BR />
	Subject(s):<BR />
	<SELECT MULTIPLE="multiple" NAME="subject" SIZE="4">
	<OPTION>General</OPTION>
	<OPTION>Aptilis</OPTION>
	<OPTION>C/C++ scripting</OPTION>
	<OPTION>Deep Space 9</OPTION>
	</SELECT><BR />
	Use [ctrl] + click to select more than one option!<BR />
	<BR />

	Your message:<BR />
	<TEXTAREA NAME="message" COLS="40" ROWS="5"></TEXTAREA><BR />

	<INPUT TYPE="submit" VALUE="Send Message" />
	</FORM>

And now, the Aptilis programme: sender2.e.txt:

sub main


	// Of course this value works for me,
	// but you may want to ask your ISP or Administrator
	// what SMTP server to use here.

	setSMTPServer("smtp.ntlworld.com")

	print("Content-type: text/html\n\n")
	print("<HTML>\n<BODY>\n\n")


	n = GetArraySize(subject[])

	if n <= 0
		allsubj = "No subject specified" $
	else

		allsubj = "" $
		for i=0 to n - 1
			allsubj = allsubj + " " + subject[i] $
		end for

	end if

	print("The subjects you have chosen are: ", allsubj$, "<br>\n")


	sendmail("nirvana@aptilis.com", from$, allsubj$, message$)
	print("Your message has been sent!")

	print("</BODY>\n</HTML>")

end main

Things learnt