You need to:
1. use your email server as the smtp, this is usually mail.yourdomain.com
2. authenticate to the smtp server
3. make sure your "From" address is exactly the same as your login address in your code
PHP
Sample php code using ASPEMAIL COM . (aspemail COM is supported by us) Please refer to this article.
If you like to use PHPMAILER, please refer to this article.
C# 1.1
private void Page_Load(object sender, System.EventArgs e)
{
MailMessage mail = new MailMessage();
mail.To = "me@mycompany.com";
mail.From = "you@yourcompany.com";
mail.Subject = "this is a test email.";
mail.Body = "Some text goes here";
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "my_username_here"); //set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "super_secret"); //set your password here
SmtpMail.SmtpServer = "mail.mycompany.com"; //your real server goes here
SmtpMail.Send( mail );
}
C# 2.0
static void Authenticate()
{
//create the mail message
MailMessage mail = new MailMessage();
//set the addresses
mail.From = new MailAddress("me@mycompany.com");
mail.To.Add("you@yourcompany.com");
//set the content
mail.Subject = "This is an email";
mail.Body = "this is the body content of the email.";
//send the message
SmtpClient smtp = new SmtpClient("mail.yourdomain.com");
//to authenticate we set the username and password properites on the SmtpClient
smtp.Credentials = new NetworkCredential("username@yourdomain.com", "secret");
smtp.Send(mail);
}
VB.net 1.1
Private Sub Page_Load(sender As Object, e As System.EventArgs)
Dim mail As New MailMessage()
mail.To = "me@mycompany.com"
mail.From = "you@yourcompany.com"
mail.Subject = "this is a test email."
mail.Body = "Some text goes here"
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1") 'basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "my_username_here") 'set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "super_secret") 'set your password here
SmtpMail.SmtpServer = "mail.mycompany.com" 'your real server goes here
SmtpMail.Send(mail)
End Sub 'Page_Load
VB.net 2.0
<%@ Import Namespace="System.Net.Mail" %>
Sub Authenticate()
'create the mail message
Dim mail As New MailMessage()
'set the addresses
mail.From = New MailAddress("me@mycompany.com")
mail.To.Add("you@yourcompany.com")
'set the content
mail.Subject = "This is an email"
mail.Body = "this is the body content of the email."
'send the message
Dim smtp As New SmtpClient("mail.yourdomain.com")
'to authenticate we set the username and password properites on the SmtpClient
smtp.Credentials = New NetworkCredential("username@yourdomain.com", "secret")
smtp.Send(mail)
End Sub 'Authenticate
ASP
<%
Dim ObjSendMail
Set ObjSendMail = Server.CreateObject("Persits.MailSender")
ObjSendMail.Host = "mail.somesite.com"
ObjSendMail.From = "someone@somesite.com"
ObjSendMail.FromName = "someone"
ObjSendMail.AddAddress "somebodyelse@somesite.com"
ObjSendMail.Subject = "your subject"
ObjSendMail.Body = "your email body"
Our email server requires SMTP Authentication. Replace the username and password below.
ObjSendMail.Username = "SMTPUsername"
ObjSendMail.Password = "SMTPPassword"
On Error Resume Next
ObjSendMail.Send
If Err <> 0 Then
Response.Write "Error encountered: " & Err.Description
End If
Set ObjSendMail = nothing
%>
Perl
Please refer to this article
Coldfusion
<Cfmail server="SMTPUsername:SMTPPassword@mail.somesite.com"
from="someone@somesite.com"
to="somebodyelse@somesite.com"
subject="your subject">
your email body
</CFMAIL>