PDA

View Full Version : Sending email from a form using mail enable, formail, sendmail etc.


wireplay
2004-10-11, 17:39 PM
Hi,

Does ANYONE know how I can send email on my server from a form?

I have managed to get Jacks FORMAIL working, BUT it seems to be ignoring ALL form fields that I pass across to it - e.g. recieipient, subject etc. so I am having to hard code them into the PHP which is not ideal at all!

I am used to using a LINUX server and just bunging the content of my form to SENDMAIL via FORMAIL, but it doesnt seem that easy on the windows boxes at all!

This is dirving me crazy, PLEASE SOMEONE HELP :poke:

noaxispoint
2004-10-11, 19:28 PM
You could install somthing like JMail on your server then do your form to do a GET method. Then you would do something like:

Dim objMail
Set objMail = Server.CreateObject("JMail.Message")

objMail.Body = "A form has been submitted with the following data:" & vbcrlf

For each item in Request.QueryString

If item = "from_email" Then
objMail.From = Request(item)
End If

If item = "to_email" Then
objMail.AddRecpipent Request(item)
End If

If item = "subject" Then
objMail.Subject = Request(subject)
End If

objMail.Body = objMail.Body & item & "=" & Request(item) & vbcrlf

Next

objMail.Send localhost
Set objMail = Nothing

You may have to change localhost to the domain name of your server and allow relay for 127.0.0.1. Be sure that you do your from_email variable in the form and your to_email variable. As well as Subject. You could of course hard code those in the page.