xsharp.eu • Smtp relay server
Page 1 of 2

Smtp relay server

Posted: Fri Oct 03, 2025 10:10 am
by Horst
Hello

I had to reinstall my server and now the provider dont let me send e-mails with the old VO Class now.

Does somebody use relayserver with x# ? and has a code to share ?

Horst

Re: Smtp relay server

Posted: Fri Oct 03, 2025 10:22 am
by wriedmann
Hi Horst,
the issue is not the code to use a relayserver - that is easy. You have to have a mail server to use (and this cannot be GMail anymore).
Or do you need code to use SMTPS?
Wolfgang

Re: Smtp relay server

Posted: Fri Oct 03, 2025 12:17 pm
by Horst
Hello Wolfgang

This Code i found and you think its not enough to send mails ? You think i have to intstall a mailserver on my webserver ?
I found no text that says i have to install a mailserver.

Code: Select all

Schritte zum Versenden einer E-Mail über einen SMTP-Relay-Server in C#:

    Namespaces importieren: Stellen Sie sicher, dass Sie die notwendigen Namespaces importieren, um E-Mails zu senden:
    csharp

using System.Net.Mail;
using System.Net;

MailMessage-Objekt erstellen: Erstellen Sie ein MailMessage-Objekt und füllen Sie die Felder für Absender, Empfänger, Betreff und Körper aus.
csharp

MailMessage NetMail = new MailMessage();
NetMail.From = new MailAddress("ihreadresse@beispiel.com");
NetMail.To.Add(new MailAddress("empfaenger@beispiel.com"));
NetMail.Subject = "Betreff Ihrer E-Mail";
NetMail.Body = "Dies ist der Inhalt Ihrer E-Mail.";
NetMail.IsBodyHtml = false; // Setzen Sie dies auf true, wenn Sie HTML-E-Mails senden möchten

SmtpClient-Objekt erstellen und konfigurieren: Erstellen Sie ein SmtpClient-Objekt und konfigurieren Sie es mit den Details Ihres Relay-Servers.
csharp

SmtpClient MailClient = new SmtpClient();

// Ersetzen Sie diese Werte durch die Ihres SMTP-Relay-Dienstes (z.B. SendGrid, Mail.de, Gmail)
MailClient.Host = "smtp.ihre-relay-adresse.com"; // Hostname des SMTP-Relay-Servers
MailClient.Port = 587; // Standard-Port, kann je nach Server variieren

// Anmeldeinformationen für die Authentifizierung am SMTP-Server
MailClient.Credentials = new NetworkCredential("ihr-benutzername", "ihr-passwort");

// Aktivieren der SSL/TLS-Verschlüsselung, falls vom Server gefordert
MailClient.EnableSsl = true;

// Methode für die Zustellung der E-Mail (Network ist der Standard)
MailClient.DeliveryMethod = SmtpDeliveryMethod.Network;

E-Mail senden: Verwenden Sie die Send()-Methode des SmtpClient, um die E-Mail zu versenden.
csharp

MailClient.Send(NetMail);

Ressourcen freigeben: Es ist eine gute Praxis, die erstellten Objekte freizugeben, um Ressourcen freizugeben.
csharp

NetMail.Dispose();
MailClient.Dispose();

 

Re: Smtp relay server

Posted: Fri Oct 03, 2025 3:40 pm
by wriedmann
Hi Horst,
I would strongly discourage to use a mailserver on your webserver - maintaining a mailserver is a job on his own.
You cannot simply send mails with any sender address - you have to implement a least SPF for every domain you are using as sender address.
Your provider should offer also email send services and give you an authenticated SMTP access, and with .NET it is easy to send SMTP over SSL, but even in this case the mail server of the provider must be allowed to send mails for every domain you are using as sender domain.
Wolfgang
P.S. for a project of my wife I'm maintaining a sending only mail server that sends out many thousands of mails per day - so I know a bit about the pitfalls

Re: Smtp relay server

Posted: Fri Oct 03, 2025 6:36 pm
by VR
hi,

https://www.mailgun.com/ could be an option. It's a dedicated smtp service for transactional email.

Re: Smtp relay server

Posted: Sun Oct 05, 2025 7:24 am
by Horst
Hi Volkmar and Wolfgang

Volkmar: i dont like to be depend on a service, this can change one day and i have to run. in the worst case i will try this.

Wolfgang: i asked my provider and they told me i have to install a mailserver. i will not do that. So now i try to install SSL on the server and then i try to send mails again. A sample how to do sent mails with ssl wound be very helpfull.

Horst

ps: i am missing a xsharp libary with different function/classes from different people like you found it when clipper rules the xbase world.

Re: Smtp relay server

Posted: Sun Oct 05, 2025 8:31 am
by wriedmann
Hi Horst,
please see here:
https://riedmann.it/download/SendMailNET.zip
Wolfgang

Re: Smtp relay server

Posted: Sun Oct 05, 2025 3:56 pm
by Horst
Thanks. But :-) do you have the viaef/prg ?

Re: Smtp relay server

Posted: Sun Oct 05, 2025 5:24 pm
by wriedmann
Hi Horst,
sorry, with the redesign of our website a lot of things were lost.
This here is a COM library to be used from VO, and it contains also the source code:
https://www.riedmann.it/download/SendMailCOM.zip
Wolfgang

Re: Smtp relay server

Posted: Mon Oct 06, 2025 11:42 am
by Horst
Hi Wolfgang

Sorry, i know your very busy, but i was looking into the zip. And i think i made a misstake when i said viaef, because i cant import it to xide. Think viaef is vulcan ?

Horst