Sending mail

Discussion to talk about software related topics only.
Vernon
Posts: 177
Joined: Sat Oct 10, 2009 6:33 pm

Sending mail

Post by Vernon »

I am trying to send test mail when the mod5270 boots as follows:



SMTP_PORT = 26;

int SendMailAuth( PCSTR var_svrip, /*IP address of the smtp server */
PCSTR userid, /*AscII String to provide for RFC931 IDentification */
PCSTR pass, /*AscII String to provide for AUTH IDentification */
PCSTR from_addr, /*From E-Mail address */
PCSTR to_addr, /*To E-Mail Address */
PCSTR subject, /*E-Mail subject */
PCSTR textbody /* E-Mail body */ );


// Email variables placed with other variables
char var_user[80] = "Vernon@cttestset.net";
char var_pass[80] = "abcdefghi";
char var_svrip[80] = "mail.cttestset.com";
char var_from[80] = "vernon@cttestset.net";
char var_to[80]= "vernon@cttestset.com";
char var_sub[80]= "NETBURNER MAIL TEST";
char var_body[80] = "THE SERVER IS ON";
int SendmailResult;
int DNSResult;

This compiles but does not send mail - any suggestions ?
Vernon
Posts: 177
Joined: Sat Oct 10, 2009 6:33 pm

Re: Sending mail

Post by Vernon »

I can telnet in - the server does respond to the ip address and port 26 with a 220 message.
Vernon
Posts: 177
Joined: Sat Oct 10, 2009 6:33 pm

Re: Sending mail

Post by Vernon »

I also tried .....

char smtp_server[] = "mail.cttestset.com";
char userid[] = "Vernon@cttestset.net";
char pass[] = "abcdefghi";
char from_addr[] = "vernon@cttestset.net";
char to_addr[] = "vernon@cttestset.com";
char subject[] = "Netburner mail";
char textbody[] = "this is a netburner mail test";


int SendMailAuth( IPADDR smtp_server, /*IP address of the smtp server */
PCSTR userid, /*AscII String to provide for RFC931 IDentification */
PCSTR pass, /*AscII String to provide for AUTH IDentification */
PCSTR from_addr, /*From E-Mail address */
PCSTR to_addr, /*To E-Mail Address */
PCSTR subject, /*E-Mail subject */
PCSTR textbody /* E-Mail body */ );

Still no mail !
Vernon
Posts: 177
Joined: Sat Oct 10, 2009 6:33 pm

Re: Sending mail

Post by Vernon »

char data[]="this is a test, only a test";


while (mailSent != 1) {
mailSent = SendMailAsServer("vernon@cttestset.net",
"vernon@cttestset.com",
"netburner test", data);
OSTimeDly(TICKS_PER_SECOND * 5);
}

This compiles but does not work either ....
Vernon
Posts: 177
Joined: Sat Oct 10, 2009 6:33 pm

Re: Sending mail

Post by Vernon »

I also tried as below. I tested both plain text and base64 username and password in the array
below. It compiles but no cigar.

char var_user[80] = "xxxx";
char var_pass[80] = "xxxxxxx";
char var_svrip[80];
char var_from[80] = "vernon@cttestset.net";
char var_to[80] = "vernon@cttestset.com";
char var_sub[80] = "Netburner Test";
char var_body[80]= "this is a test, it is only a test";

int SendmailResult;
int DNSResult;



IPADDR SMTP_server;
DNSResult = GetHostByName( var_svrip, &SMTP_server, 0, TICKS_PER_SECOND * 20 );

SendmailResult = SendMailAuth( SMTP_server, var_user, var_pass, var_from, var_to, var_sub, var_body );
User avatar
Chris Ruff
Posts: 222
Joined: Thu Apr 24, 2008 4:09 pm
Location: topsail island, nc
Contact:

Re: Sending mail

Post by Chris Ruff »

Vernon

There are many possible issues.

I use SMTP port 25. from my house I can _only_ use my mail server mail.bellsouth.net because all other SMTP ports are blocked by my ISP. (In this manner spammers can't operate from this ISP's domain contacting various SMTP servers out on the internet to relay evil mail)

So you have to use an SMTP server that you can get to.

Your mail server may or may not accept:

auth none, auth login, auth cram md5, auth plain, and there are more including TLS authentication- not at all fun

from the code-
//
// Some SMTP servers are set up to reject all relaying on port 25,
// but valid users authenticating on port 587 are allowed to
// relay mail to any valid address.
//
// A server that relays all email for all destinations for
// all clients connecting to port 25 is known as an open relay
// and is now generally considered a bad practice worthy of
// blacklisting.
//

So your server may have certain requirements, if you are able to reach it.

If you are working from within a carefully maintained domain at work your Netburner toy may not have the authorization to send out e-mail. You may need to grant the IP address you are on the permission to send mail out

...............

I was able to get my email code working by learning the SMTP commands and typing in the mail commands, authorization strings, mail subject and body into Telnet.

..talking with my SMTP server...

me:
TELNET mail.bellsouth.net 25
SMTP:
220 isp.att.net - Maillenium etc. etc.
me: etc.
it: etc.


...........

Have you worked with all of the examples Netburner has?

.............

Have you checked your Junk folder. I find that nearly all emails my devices generate end up in spam folders and my customers have to educate their filters to allow the messages

.............

Start with Netburner's examples on *your* SMPT server

If you can get them to work you should be able to get your system working with your server.
If you can get to other SMTP servers on the internet that you have an account with you can relay out of them, but it will certainly require authentication of some flavor



Chris
Real Programmers don't comment their code. If it was hard to write, it should be hard to understand
Ridgeglider
Posts: 513
Joined: Sat Apr 26, 2008 7:14 am

Re: Sending mail

Post by Ridgeglider »

Have you tried the email example files: C:\nburn\examples\Email?
Vernon
Posts: 177
Joined: Sat Oct 10, 2009 6:33 pm

Re: Sending mail

Post by Vernon »

This SMT server is on a website that I own. One possible issue is the fact that I had to set the port to 26 in outlook express - for some reason they use 26.

Are the commands passed to SendMailAuth in the same sequence as a telnet in ? If I have an order of strings is that what works ?

I did telnet in up to the point where it asked for the base64 username.
rnixon
Posts: 833
Joined: Thu Apr 24, 2008 3:59 pm

Re: Sending mail

Post by rnixon »

The netburner example does a diagnostic if things fail. Have you tried it?
Vernon
Posts: 177
Joined: Sat Oct 10, 2009 6:33 pm

Re: Sending mail

Post by Vernon »

The only example I found is one that requires entry of all the info on a web page. Since I want the Netburner to send an email at a certain data value at my geiger counter site -

http://www.pahrumpgeigercounter.com/

I don't need the web email interface.

I think the problem is the required pattern of inputs after authentication is accepted - as follows:
235 Authentication succeeded (from server)
MAIL FROM: telnet vernon@cttestset.com (I type this)
250 OK (from server)
RCPT TO: vernon@cttestset.com (I type this)
250 Accepted (from server)
DATA ( I type this)
354 Enter message, ending with "." on a line by itself (from server)
Date: Fri, 16 Dec 2011 02:05:25 -0600 **(note: If omitted, date will be set to "12/31/1969 5PM") (I have the option of typing this)
FROM: telnet vernon@cttestset.com (I type this)
TO: vernon@cttestset.com (I type this)
**note: use the same "From" and "To" fields as MAIL FROM and RCPT TO above. If these are omitted, you will get a '550 administrative prohibition' error.
Subject: Testing [telnet]

**Note: The subject line should be followed by an extra line return.
This is the message body
.
**Note: above line is a period followed by a Return
250 OK id=1Idho3-0005Xw-TA
Message successfully sent
**Note: If there are any errors sending (like '550 administrative prohibition') they would appear in place of "Message successfully sent"

I am wondering if the sendmailauth routine complies with this pattern and actually sends the email addresses twice - does anybody know ?
Post Reply