Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

faq184-3840 Sending SMTP Mail

Status
Not open for further replies.

torturedmind

Programmer
Jan 31, 2002
1,052
0
0
PH
Good day to all.

What will I include in the config part of this FAQ to log-in to our SMTP server using a different user and/or password?

TIA

kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 
SMTP is the name of a protocol, not a server, we are talking about a mail server.

If you host your own mail server in your corpoaration you are setting credentials, if you are using a mail server from the mail provider (eg smtp.gmail.com) they should tell you cedentials. Typically you use your mail adress as user name (sometimes without the @domain part, sometimes not) and the password you have set or got, eg for using webmail (mail.google.com), because - well - how else would the web mail client know how t connect to the mail server?

Just google your mail provider mail server name, sometimes it's two names, one for sending, th other for receiving, there are a lot of lists with the credential in principle (not the concrete credentials of specific mail accounts of course). Google is a bad example, as it only allows SSL (ecrypted) connections.

Bye, Olaf.
 
Using Winsock it's cumbersome, you have to send and receive several commands for the authentication. So the initial connect is without credentials, you login via sending some commands and waiting for responses and only after that can send a mail. With CDO.Configuration that's simpler, there are additional settings for that:

Code:
    iConf = Createobject("CDO.Configuration")
    Flds = iConf.Fields
    With Flds
        .Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")[/URL] = 2
        .Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] = 'Your SMTP server name here'
        .Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserverport")[/URL] = 25
        [COLOR=#4E9A06].Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")[/URL][/color] = [COLOR=#A40000]<<authenticationmethod (1=BASIC, 2=NTLM)>>[/color]
        [COLOR=#4E9A06].Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusername")[/URL][/color] = [COLOR=#A40000]"<<your username, typically mailadress>>"[/color]
        [COLOR=#4E9A06].Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendpassword")[/URL][/color] = [COLOR=#A40000]"<<yourpassword>>"[/color]
        .Update()
    Endwith

Bye, Olaf.
 
Thanks. I got it working using CDO.[thumbsup2] Just wondering what's the equivalent using winsock.

kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 
Winsock: I said you use smtp commands via the connection you do without any credentials.
It's complicated you don't simply have two or three additional settings to do, you send commands and react to responses.

[URL unfurl="true"]http://www.fehcom.de/qmail/smtpauth.html[/url]

Forget about it, I never did it and wouldn't do it, as there are simpler methods. I'd recommend using BLAT.DLL instead and outlook automation is also much simpler, the SMTP/POP or also IMAP configuration then is not your task, that's Oulook configuration.

Bye, Olaf.
 
I use Rick Strahl's WestWind tools to send thousands of emails every day from my various on-line apps.

It is really reliable, and simple to implement.


Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
In fact, here is a really simple 'quick email' function using the wwiptools:

Code:
m.SMTPSERVER = "mail.somewhere.com"
m.SMTPNAME = "me@somewhere.com"
m.SMTPUSERNAME = "me.somewhere.com"
m.SMTPPASSWORD = "myPassWordForEmailServer"

QUICKEMAIL("someone@somewhere.com","Hi from me")


FUNCTION QUICKEMAIL
	PARAMETERS m.EMAILADDRESS,m.MESSAGESTRING
	PRIVATE m.EMAILADDRESS,m.MESSAGESTRING,I
	LOCAL LLRESULT
	SET CLASSLIB TO WWIPSTUFF
	OIPSTUFF=CREATEOBJECT("wwIPStuff")

	FOR I = 1 TO MEMLINES(m.EMAILADDRESS)
		IF !EMPTY(MLINE(m.EMAILADDRESS,I))
			OIPSTUFF.CMAILSERVER=m.SMTPSERVER
			OIPSTUFF.CSENDEREMAIL=m.SMTPNAME
			IF !EMPTY(m.SMTPUSERNAME)
				OIPSTUFF.CUSERNAME = m.SMTPUSERNAME
			ENDIF
			IF !EMPTY(m.SMTPPASSWORD)
				OIPSTUFF.CPASSWORD = m.SMTPPASSWORD
			ENDIF

			OIPSTUFF.CSENDERNAME=m.SYSTEMNAME+" Alert "

			OIPSTUFF.CRECIPIENT=MLINE(m.EMAILADDRESS,I)

			OIPSTUFF.CSUBJECT= 	MLINE(m.MESSAGESTRING,1)
			OIPSTUFF.CMESSAGE= m.MESSAGESTRING
			OIPSTUFF.CATTACHMENT=""
			OIPSTUFF.LRETURNRECEIPT = .F.
			LLRESULT = OIPSTUFF.SENDMAIL()
			IF !LLRESULT
				WAIT OIPSTUFF.CERRORMSG WINDOW  TIMEOUT 20
			ENDIF
			WAIT CLEAR
		ENDIF
	NEXT
	RELEASE CLASSLIB WWIPSTUFF
	RELEASE OIPSTUFF

	RETURN(.T.)

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
Thanks guys. Tried blat a long time ago using the dll but gave up on it because of the attachment issue. Its shell works ok though. Anyways, i think i'll give blat another shot. Maybe things have changed for the better.

kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 
What problem? The documentation of blat is sparse, but complete. The command line switches are overseeable. Normal rules apply, eg you put file names with spaces in quotation marks.
For ease of use you prepare some files with body, list of recipients, list of attachments and use the command line switches for specifying these files (-tf -af) instead of directly specifying values in the commandline (-to -attach).
The body is expected in a separate file you specify without any command line switch, unless you override that and start your commandline with - -body "This ia a test message".

[URL unfurl="true"]http://www.blat.net/syntax/syntax.html[/url]

You need a 32bit version, currently blat324_32.full. You just pick out the BLAT.DLL from there. You only need one function "Send" of the DLL, which you declare via
[pre]Declare Integer Send In blat.dll String cCommandline[/pre]

You then put together a command line as you'd do for the EXE in a variable lcCommandline and call Send(lcCommandline).

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top