PDA

View Full Version : Problems with Emailing a Form using JMail


Starlight
01-06-2004, 04:57 PM
I have a form set up where when the user enters the details and clicks 'OK' it should (in theory!) send the receiptant an email. I am using the JMail.Message object.

Everytime, the "Send" command fails and I get the following error message:-

Error Type:
jmail.Message (0x8000FFFF)
The message was undeliverable. All servers failed to receive the message
/agm/online-enquiry-form.asp, line 36

I also get the same error when using the JMail.SMTPMail object to. I have also used the IP address as well as the hostname. My code is below.

If you have any ideas or suggestion or why I would get an error then please let me know.

Thanks in Advance! :thumbsup:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Request.QueryString
End If

If (CStr(Request("MM_OKHidden")) = "onlineForm") Then

' smtpServer = "151.182.138.111"
' smtpPort = 25

' ---
dim sender, subject, body, smtpServer, smtpPort

'Now gets the data from Form
sender = Request.Form("sender")
receiver = Request.Form("receiver")
subject = Request.Form("subject")
body = Request.Form("body")
Response.Write(body)

set msg = Server.CreateObject("JMail.Message")

msg.Clear()
msg.Logging = true
msg.From = sender
msg.FromName = "Alex"
msg.AddRecipient receiver
msg.Subject = subject
msg.Body = body

Response.Write(msg.Log)
Response.Write(msg.Body)

msg.Send("151.182.138.111")

msg.Close()

' mail.ServerAddress = smtpServer & ":" & smtpPort
' mail.Sender = sender
' mail.Subject = subject
' mail.AddRecipient receiver
' mail.ContentType = "text/html"
' mail.ISOEncodeHeaders = false
' mail.ContentTransferEncoding = "8bit"
' mail.Body = body
' mail.Priority = 3
' mail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR")
' mail.Execute
' set mail = nothing
End If

If (CStr(Request("MM_OKHidden")) <> "") Then
End If
%>

<html>
<head>
<title>OnLine Enquiry Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor=aliceblue text="#003366" style="font-family:Verdana">
<div align="center">
<p>&nbsp;</p>
<p><font size="+2">Online Enquiry Form </font></p>
<p></p>
</div>
<form method="post" action="<%=MM_editAction%>" name="onlineForm">
<table width="75%" border="1" align="center">
<tr>
<td>Online Enquiry</td>
<td><input type="text" name="onlineenquiry"></td>
</tr>
<tr>
<td>Name</td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td>Company Name</td>
<td><input type="text" name="compname"></td>
</tr>
<tr>
<td>Contact Tel.</td>
<td><input type="text" name="telephone"></td>
</tr>
<tr>
<td>Your EMail Address</td>
<td><input type="text" name="sender" value="ap.higginson@tiscali.co.uk"></td>
</tr>
<tr>
<td>Receiver's Email Address</td>
<td><input type="text" name="receiver" value="innes.beaton@aeat.co.uk" readonly="true"></td>
</tr>
<tr>
<td>Subject</td>
<td><input type="text" name="subject" value="Test"></td>
</tr>
<tr>
<td>Body</td>
<td><textarea name="body"></textarea></td>
</tr>
<tr>
<td>Use of Product</td>
<td><textarea name="productuse"></textarea></td>
</tr>
<tr>
<td>Product Data Sheets</td>
<td>&nbsp;</td>
</tr>
</table>

<div align="left">

<p align="center">
<input name="MM_OK" type="submit" id="MM_OK" value=" OK " style="font-family:Verdana; color: #215DC6; background-color: #D6DFF7">
<input type="hidden" name="MM_OKHidden" value="onlineForm">
</p>
</div>
<div align="center"></div>
</form>
</body>
</html>

A1ien51
01-07-2004, 01:56 PM
Just a quick thought that seems to be people's problems:
Does the server you are on allow you to send emails from it?