Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Shells Virtual Desktop
BMail.ag - Secure Email Service
Server.net
CPLicense.net
VPS Server
Buy VPN
Vultr
VMs for AI
HostDare
HostDare
ReliableSite White-Label Dedicated Hosting for Resellers
InterServer VPS
BMail.ag - Secure Email Service
Best VPN
High-Performance Bare Metal Server Solutions
Karvl.com
Server Mania Cloud Hosting
DataWagon Hosting
AlphaVPS Hosting
Evoxt.com
Clouvider
VPS Hosting with NVMe
Residential IPs in the US & 4G Mobile Proxies in EU & US with Unlimited Bandwidth
ReliableSite White-Label Dedicated Hosting for Resellers
Rabisu - Hosting Solutions
Shells Virtual Desktop
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

.NET equivalent of PHPMailer

mailcheapmailcheap Member, Host Rep

Hey everyone :)

What would be the .NET (C#) equivalent of the following PHPMailer code:

$mailServerType = 'smtp';
//IF $mailServerType = 'smtp'
$smtp_server = 'example.mymailcheap.com';
$smtp_user = '[email protected]';
$smtp_pw = 'UserPassword';
$smtp_port = 587;
$smtp_security = 'tls';

The following code is rejected by mail server as "Transaction failed. The server response was: 5.7.1 Client host rejected: Access denied"

SmtpClient client = new SmtpClient();
client.Port = 587;
client.Host = "example.mymailcheap.com";
client.EnableSsl = true;
client.Timeout = 10000;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("[email protected]", "UserPassword");
MailMessage mm = new MailMessage("[email protected]", "[email protected]", "test", "test");

mm.BodyEncoding = UTF8Encoding.UTF8;

mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;

client.Send(mm);

I would guess the EnableSsl has to be changed to TLS or something equivalent. Server uses STARTTLS. Unfortunately I have no experience in .NET and appreciate any help!

Thanks and Best Regards,
Pavin Joseph.

Comments

Sign In or Register to comment.