PHP has built-in mail() function which can be used to send email without authentication. You just need to make sure that server is properly configured to relay email via PHP script. When you use PHP mail(), it does not use SMTP authentication to relay email. Following us the sample script to send email using PHP […]
You may need to connect to your Microsoft SQL server from your PHP script. It is possible to connect to SQL server using PHP script. There is PHP MSSQL driver available which can be used to connect to Microsoft SQL server from PHP script. Following is the sample script to connect to your SQL server […]
An OLE DB connection enables to connect to a data source by using an OLE DB provider. For example, an OLE DB connection manager that connects to Microsoft Access database or SQL Server can use the Microsoft Access Jet or Microsoft OLE DB Provider for SQL Server. Following is the sample connection string for Microsoft […]
ASP.Net has built in class to send email. You can send email with or without authentication. In our previous post we provided sample script to send email from ASP.Net using VB.Net code. In this post, we will provide you sample code to send email from ASP.Net using C# code. Following is the sample code to […]
ASP.Net has built in class to send email via script. You can send email with or without authentication using ASP.Net namespace System.Net.Mail. Following is the sample code to send mail using ASP.Net (VB.Net):
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Net.Mail" %>
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim strFrom = "email@example.com"
Dim strTo = "firstname.lastname@example.org"
Dim MailMsg As New MailMessage(New MailAddress(strFrom.Trim()), New MailAddress(strTo))
MailMsg.BodyEncoding = Encoding.Default
MailMsg.Subject = "This is a test email using VB.Net Code"
MailMsg.Body = "This is a test email using VB.Net Code"
MailMsg.Priority = MailPriority.High
MailMsg.IsBodyHtml = True
Dim SmtpMail As New SmtpClient
Dim basicAuthenticationInfo As New System.Net.NetworkCredential("email@example.com", "password")
SmtpMail.Host = "smtp.yourdomain.com"
SmtpMail.UseDefaultCredentials = False
SmtpMail.Credentials = basicAuthenticationInfo
lblMessage.Text = "Mail Sent"
<asp:Label id="lblMessage" runat="server"></asp:Label>
Make sure to make necessary changes in your script (i.e. SMTP server, email address, password etc.)
If you want to check available PHP modules and their limit (PHP memory, PHP execution time, max_upload size etc.), you can write simple PHP script to check it. Using the following sample code and upload it in your website:
When you access your page, it will show the output as follow: If phpinfo function […]
On Windows server, you can send mail using CDO. CDO allows to send email using SMTP authentication as well as without SMTP authentication. Here is the sample code to send email using SMTP authentication using CDO:
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "firstname.lastname@example.org"
objEmail.To = "email@example.com"
objEmail.Subject = "Test Mail"
objEmail.Textbody = "Test Mail"
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "SMTP SERVER NAME"
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = "1"
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "firstname.lastname@example.org"
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "Email_Account_Password"
If Not err.number=0 Then
Response.write "ERROR: " & err.Description
Response.write "Email sent to " & objEmail.To
You will have to update SMTP server, SMTP username and password in the above sample script.