Mailhandler opsætning
Hejsa,er ved at sætte mailhandler script op på mit one.com domain og det virker bare ikke... virker fint på hjemmesiden men modtager intet.
På selve hjemmesiden har jeg denne kode:
<form id="contact-form">
<fieldset>
<div class="wrapper">
<div class="success"> Contact form submitted! <br> <strong class="color-3">We will be in touch soon.</strong> </div>
</div>
<div class="field">
<label class="name">
<input type="text" value="Name:">
<span class="error">*This is not a valid name.</span> <span class="empty">*This field is required.</span>
</label>
</div>
<div class="field">
<label class="email">
<input type="text" value="E-mail:">
<span class="error">*This is not a valid email address.</span> <span class="empty">*This field is required.</span>
</label>
</div>
<div class="field">
<label class="phone">
<input type="text" value="Phone:">
<span class="error">*This is not a valid phone number.</span> <span class="empty">*This field is required.</span>
</label>
</div>
<div class="area">
<label class="message">
<textarea>Message:</textarea>
<span class="error">*The message is too short.</span> <span class="empty">*This field is required.</span>
</label>
</div>
<div class="clear"></div>
<div class="buttons-wrapper">
<a class="button-4" data-type="reset"><span><span>Clear</span></span></a>
<span class="left-indent"><a class="button-4" data-type="submit"><span><span>Submit</span></span></a></span>
</div>
</fieldset>
</form>
På selve server ligger denne mailhandler.ASHX fil:
<%@ WebHandler Language="C#" Class="Handler" Debug="true" %>
using System;
using System.Web;
using System.Net.Mail;
using System.Text.RegularExpressions;
public class Handler : IHttpHandler {
public void ProcessRequest (HttpContext context) {
SmtpClient mailClient = new SmtpClient(context.Request.Form.Get("smtpMailServer"));
string owner_email = context.Request.Form.Get("owner_email");
string subject = "A message from your site visitor " + context.Request.Form.Get("name");
string email = context.Request.Form.Get("email");
string messageBody = "";
messageBody += "<p>Visitor: " + context.Request.Form.Get("name") + "</p>\n";
messageBody += "<br>\n";
messageBody += "<p>Email Address: " + context.Request.Form.Get("email") + "</p>\n";
messageBody += "<br>\n";
messageBody += "<p>Phone Number: " + context.Request.Form.Get("phone") + "</p>\n";
messageBody += "<br>\n";
messageBody += "<p>Message: " + context.Request.Form.Get("message") + "</p>\n";
MailMessage message = new MailMessage();
try{
message.From = new MailAddress(email.ToString());
}catch (FormatException e) {
context.Response.Write(e.Message);
}
message.To.Add(owner_email);
message.Subject = subject;
if(context.Request.Form.Get("stripHTML") == "true"){
message.IsBodyHtml = false;
messageBody = Regex.Replace(messageBody, "<.*?>", string.Empty);
}else{
message.IsBodyHtml = true;
}
message.Body = messageBody;
try{
mailClient.Send(message);
}catch (SmtpException e) {
context.Response.Write("mail failed");
}
context.Response.Write("mail sent");
}
public bool IsReusable {
get {
return false;
}
}
}
One.com har kun kunnet hjælpe med smtp er mailout.one.com
Håber en kan hjælpe mig med at få det til at virke sammen.
Takker Kim