LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SMTP Email Send Message

I'm trying to figure out how to use the "SMTP Email Send Message (small).vi"   (for no reason other than I'm curious if it will work).

I've figured out all of the inputs so far, since they are self explanitory, except  mail server.

 

For the mail server, what format is the vi looking for. For example, are any of these correct?

- Yahoo

- http://www.yahoo.com

- http://mail.yahoo.com

etc.

 

Can someone give me an example of what to input for mail server. 

Cory K
0 Kudos
Message 1 of 10
(5,779 Views)

The mail server is simply a machine name, no protocol - for example, try "a.mx.mail.yahoo.com" for Yahoo.  You should read a bit about SMTP to understand how email messages are sent, otherwise you'll probably find that your messages don't get delivered and you won't know why. 

 

Here's a brief explaination:  In general you send email through a "relay" that accepts your mail and delivers it to its final recipient.  However, all properly-configured relays now require some sort of authentication before they'll accept email, otherwise spammers abuse them.  Sometimes that authentication is as simple as only accepting emails from a range of IP addresses, and sometimes it's as complicated as requiring an encrypted password exchange or login to a POP server.  The SMTP Send Message VI doesn't handle any of that, unless your mail relay restricts based on IP address and yours is in the right range.  If you don't have a usable relay, your other option is to send directly to the mail exchanger for your recipient.  You can look that up using nslookup on a windows machine; set the querytype to "mx" and look up the target domain.  This works fine if you need to send email to a known address and can hardcode the server, but is a pain if you need to be able to enter different email addresses at runtime.  Also, it's not terribly reliable - with a properly configured relay, if your mail can't be delivered, it will fall back to a secondary server if available, and if that doesn't work it will queue the message and attempt delivery later; with the SMTP Send Email VI you get a single shot at sending it directly to a single server, and if that fails you get an error and have to retry manually.

 

Despite the above, I've had no problems using the SMTP VIs for emails when I was able to hardcode the appropriate address and mail server.

Message Edited by nathand on 09-04-2008 12:49 PM
Message 2 of 10
(5,771 Views)

Thanks, that worked great.

 

is "a.mx" a universal prefix before you type the mail server, or was that specific to yahoo? 

Cory K
0 Kudos
Message 3 of 10
(5,764 Views)

You'd need to put the correct server for your PC, as security constraints at SMTP servers now generally only allow to send through your own ISP's servers (Sweeping generalisation) The format of the server name will be something like "mail.yahoo.com" to use the domain you used. It will most certainly NOT begin with "http://".

 

To get the correct value, look in your email client's parameters fo the SMTP server, and copy what you see there, or ask your IT department what you should use. BTW If your server needs authentication, (again your IT department should be of help here) the NI-supplied vi's (at least at 8.2) won't work, but I believe that an open-G alternative does work.

 

Rod.

 

Edit: Got beaten to the punch by another (fuller) answer!

 

PS. There's no universal/standard prefix, (yahoo is in my experience a bit unusual in its server's prefix. You'll find that a simple "mail" or "smtp" quite common. But it's up to each ISP what to call the server. I've even just been supplied a dotted quad IP address!

Message Edited by Rod on 09-04-2008 05:57 PM
Message Edited by Rod on 09-04-2008 06:01 PM
Message 4 of 10
(5,762 Views)

OK, thanks.

Look at that, you learn something new every day 🙂

Cory K
0 Kudos
Message 5 of 10
(5,756 Views)

There is no universal prefix, although "mx" is common.  You can use "nslookup" to find the mail exchanger for a given domain name.  For example (at a command prompt):

C:\>nslookup
Default Server: 
Address: 

> set querytype=MX
> yahoo.com
Server: 
Address: 

yahoo.com       MX preference = 1, mail exchanger = f.mx.mail.yahoo.com
yahoo.com       MX preference = 1, mail exchanger = g.mx.mail.yahoo.com
yahoo.com       MX preference = 1, mail exchanger = a.mx.mail.yahoo.com

Message 6 of 10
(5,755 Views)
OK, that is the craziest thing I have ever seen.
Where do people learn stuff like this?
Cory K
0 Kudos
Message 7 of 10
(5,750 Views)

Well, this seems to be working for Gmail, yahoo, aol so far.

For some reason my school email isnt working though.

For michigan state university, email can be found at mail.msu.edu.

 

I used the command prompt to search for the mail server and found

lb.mail.msu.edu

however I keep getting the message : "The network connection has been closed by the peer"

Does that mean there is some kind of security blocking the message? 

Cory K
0 Kudos
Message 8 of 10
(5,742 Views)

That error suggests that your IP range is blocked from sending mail through that mail exchanger.  It's probably not your fault and there's probably nothing you can do about it - blame the spammers.

0 Kudos
Message 9 of 10
(5,709 Views)
"blame the spammers" ...... they are usually the source of all problems :smileywink:
Cory K
0 Kudos
Message 10 of 10
(5,642 Views)