Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Any way to know if email is valid?
Message
 
À
01/02/2006 16:18:59
Information générale
Forum:
Visual FoxPro
Catégorie:
Applications Internet
Divers
Thread ID:
01092572
Message ID:
01092699
Vues:
22
This message has been marked as a message which has helped to the initial question of the thread.
>The database contains many email adresses. Some of those adresses are old others are recent.
>
>Is there a way to test for the validity of an address before sending a message to that address?

Depends.... In NET if you try to send an email thru an explicit SMTP server it will error out as soon as the SMTP is contacted if the address is malformed or the SMTP server knows that the email address is bad. In addition, if you send thru an explicit SMTP server using an explicit account/username/reply-to it will bounce back to the inbox for that account. This code will assist with that:
protected void btnSaveUser_Click(object sender, EventArgs e)
	{
	Page.Validate();
	if (IsValid)
	{
	string strMessage = "<html>";
	strMessage += "<html><body bgcolor='#FFFFFF'><center><table width='90%' border='0' bgcolor='#FFFFFF' style='border: 4px solid #CCCCCC;'><tr><td>";
	strMessage += "<span style='FONT-SIZE: 10px; COLOR: #003399; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif'>";
	strMessage += txtName.Value=="" ?  "<strong>From:</strong>     No Name Given <BR>" : "<strong>From:</strong>     " + txtName.Value  + "<br>";
	strMessage += txtPhone.Value=="" ? "<strong>Phone:</strong>    No Phone Given<BR>" : "<strong>Phone:</strong>    " + txtPhone.Value + "<br>";
	strMessage += txtEmail.Value=="" ? "<strong>Email:</strong>    No Email Given<HR>" : "<strong>Email:</strong>    <a href='Mailto:" + txtEmail.Value + "'>"+ txtEmail.Value + "</a><hr>";
	strMessage += txtComment.Value=="" ? "<strong>Comment:</strong><br>No Comment Given<BR>" : "<strong>Comment:</strong><br>    " + StringHelper.HTMLfy(txtComment.Value);
	strMessage += "</span></td></tr></table></center></body></html>";

	MailMessage mail = new MailMessage();
	mail.To = GetEmail(int.Parse(selTopic.Value));
	mail.From = "contact@someplace.com";
	mail.Subject = "Inquiry - " + GetDescription(int.Parse(selTopic.Value));
	mail.BodyFormat = MailFormat.Html;
	mail.Body = strMessage;
	mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");	//basic authentication
	mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", ConfigReader.GetMailUser()); //set your username here
	mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", ConfigReader.GetMailPassword());	//set your password here
	SmtpMail.SmtpServer = ConfigReader.GetMailServer();  //your real server goes here
	SmtpMail.Send( mail );
	Response.Redirect(Pages.ContactConfirm, true);
			}
This does involves sending email. Other than validating against the DNS server there is really no reliable way to validate email all the way unless you send something out since some mail servers poll for delivery with a delay (1 minute or so), or all depends on the smtp server load at the time so even the method above will give you a false positive. Perhaps sending out and checking for bounces is the most reliable way. In that case you can hide a code (record id, for example) in the header of the email, so when it bounces you can automate the read of those headers and get a report of bad emails.
Ricardo A. Parodi
eSolar, Inc.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform