Send Email from ASP using JMail
JMail is a popular COM component used to send email from classic ASP pages. It provides a simple way to integrate email functionality into your website. Below you’ll find a sample script and important notes on configuration.
Sample JMail Code
<%
Set JMail = Server.CreateObject("JMail.Message")
JMail.Logging = true
JMail.Charset = "ISO-8859-1"
' Sender and recipient details
JMail.From = "me@mydomain.com"
JMail.FromName = "My Website"
JMail.AddRecipient "recipient@test.com"
' Message content
JMail.Subject = "Example JMail Message"
JMail.Body = "This is a sample message sent using JMail."
' SMTP server configuration
JMail.MailServerUserName = "me@mydomain.com"
JMail.MailServerPassword = "yourpassword"
JMail.Send("mail.mydomain.com")
%>
Important Notes
- Emails must be sent from a valid email address hosted on Fast2Host servers. Otherwise, authentication will fail and the email will not be sent.
- Replace
mail.mydomain.comwith your actual SMTP server hostname. - Use your full email address and password for authentication.
- Always test your script by sending to a known recipient before deploying.
Best Practices
- Enable SSL/TLS: If your hosting supports secure connections, configure JMail to use SSL for added security.
- Use alternate SMTP ports: If port 25 is blocked by your ISP, use Fast2Host’s alternate ports (Windows hosting: 49, Linux hosting: 26).
- Log errors: Enable JMail logging to troubleshoot delivery issues.
- Validate input: Always sanitize form input to prevent abuse or injection attacks.
✔ Tip: JMail is suitable for legacy ASP sites. For modern ASP.NET applications,
consider using
System.Net.Mail for better security and compatibility.