Smtp relay server

This forum is meant for questions and discussions about the X# language and tools
User avatar
Chris
Posts: 5472
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: Smtp relay server

Post by Chris »

Hi Horst,

xiaef/viaef is the same thing, app export file for XIDE which used to be called VIDE. You need to import it with (main menu) Application->Import Application
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
Horst
Posts: 345
Joined: Tue Oct 13, 2015 3:27 pm

Re: Smtp relay server

Post by Horst »

Hello
Thanks Chris and Wolfgang
I coud make a Testfunction , but the Mails are not going out.
The error message says nothing to me, is it possible get better information about the error ?

Code: Select all

Error at SmtpSender:Process:
Fehler beim Senden von Mail.
   bei System.Net.Mail.SmtpClient.Send(MailMessage message)
   bei _Swissbase-Functionen.Functions.TestMail(__Usual[] Xs$Args) in C:\XIDE\Projects\Swissbase\Applications\_Swissbase-Functionen\Klassen\SmtpSsl_Sender.prg:Zeile 185.

Code: Select all

FUNCTION TestMail () AS LOGIC
	LOCAL oMessage				AS MailMessage
	LOCAL lReturn	:= TRUE		AS LOGIC
	LOCAL oSmtpClient			AS SmtpClient

	oMessage			:= MailMessage{}
	oMessage:Subject	:= "Betrifft Auftrag KB 111111"
	oMessage:Body		:= "<b>Das ist der E-Mail Text im MailBody als Html</b>"
	oMessage:IsBodyHtml	:= TRUE
	oMessage:Sender		:= MailAddress{ "bla@swissbase.ch"}
	oMessage:@@From		:= MailAddress{ "bla@swissbase.ch" }
	oMessage:@@to:Add	( "korijn@gmx.ch" )
	oMessage:Headers:Add( "X-Mailer", "cXMailer was ist das " )
	
	TRY   
	
	oSmtpClient						:= SmtpClient{}
	oSmtpClient:Host					:= "mail.fritz.gmbh"
	oSmtpClient:Port					:= 587
	oSmtpClient:DeliveryMethod		 	:= SmtpDeliveryMethod.Network
	oSmtpClient:UseDefaultCredentials	:= FALSE
	oSmtpClient:Credentials				:= NetworkCredential{ "bla@swissbase.ch", "Passwort"}
	oSmtpClient:EnableSsl				:= TRUE

	oSmtpClient:Send( oMessage )

	CATCH oEx AS Exception
		                                                                                
	myerr (  "Error at SmtpSender:Process:" + CRLF + oEx:Message + CRLF + oEx:StackTrace)	
	lReturn				:= FALSE
	   
	END TRY
	
	oSmtpClient			:= NULL
	oMessage			:= NULL
	
    RETURN lReturn
User avatar
wriedmann
Posts: 4018
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Re: Smtp relay server

Post by wriedmann »

Hi Horst,
one note:
Explicit SSL (mostly port 465) is NOT supported by the SMTPClient class
Implicit SSL (mostly port 25) IS supported by the SMTPClient class
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Horst
Posts: 345
Joined: Tue Oct 13, 2015 3:27 pm

Re: Smtp relay server

Post by Horst »

Hello Wolfgang

Sorry , i dont understand what you wanna tell me.

I tryed 465 and 587 .
With thunderbird on the server i can send mails.

Do you think my little Testfunction shoud work ?
Do i have make some changing on the server ?
Is it possible to get more information form oEX ?

Ich steh am Berg :-)

Horst
FFF
Posts: 1732
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

Re: Smtp relay server

Post by FFF »

Hi Horst,
i use almost identical your code (ie Wolfgang's) over port 587, which works flawless for years, BUT sometimes my mails got blocked, if the receiver is with "gmx.de". For completeness, did you try another adress?
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
User avatar
Horst
Posts: 345
Joined: Tue Oct 13, 2015 3:27 pm

Re: Smtp relay server

Post by Horst »

Hello Karl

I changed the sender and receiver and it works.

So i have to look why.
Thanks
Horst
User avatar
wriedmann
Posts: 4018
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Re: Smtp relay server

Post by wriedmann »

Hi Horst,
what I mean: for SMTP over SSL there are two different types: implicit SSL (that means that the server expects only SSL connections) and explicit SSL (that means that the client connects to the server and then asks to switch to SSL).
The SMTPClient class supports only implicit SSL and not explicit SSL.
Unfortunately the world of protocols is not always as easy as we hope.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Post Reply