Smtp relay server

This forum is meant for questions and discussions about the X# language and tools
User avatar
Horst
Posts: 345
Joined: Tue Oct 13, 2015 3:27 pm

Smtp relay server

Post 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
User avatar
wriedmann
Posts: 4017
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Re: Smtp relay server

Post 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
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

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();

 
User avatar
wriedmann
Posts: 4017
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Re: Smtp relay server

Post 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
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
VR
Posts: 113
Joined: Sun Aug 23, 2020 3:07 pm
Location: Italy

Re: Smtp relay server

Post by VR »

hi,

https://www.mailgun.com/ could be an option. It's a dedicated smtp service for transactional email.
User avatar
Horst
Posts: 345
Joined: Tue Oct 13, 2015 3:27 pm

Re: Smtp relay server

Post 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.
User avatar
wriedmann
Posts: 4017
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Re: Smtp relay server

Post by wriedmann »

Hi Horst,
please see here:
https://riedmann.it/download/SendMailNET.zip
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 »

Thanks. But :-) do you have the viaef/prg ?
User avatar
wriedmann
Posts: 4017
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Re: Smtp relay server

Post 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
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 »

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
Post Reply