Sending mail using SMTP settings? - asp.net

I have a code for sending mail using SMTP settings in asp.net. That code is working well on live but when i am testing the same on localhost. It shows the error:
Mailbox unavailable. The server response was: 5.7.1 Unable to relay for abc.xyz.com
I know this is some configuration related error, but i don't know exactly what i need to change to test the same on localhost. I have defined these attributes for SMTP:
smtp.Host = "abc.server.net";
smtp.Port = 123;
smtp.EnableSsl = false;
fromEmail="any email";
password="password"
Any help would be appreciated.

You have to configure relay restrictions in the IIS admin. see this article
try this
Open IIS Manager using Control Panel --> Administrative Tools.
Open SMTP Virtual Server properties.
On General tab, Set IP address of the Web server instead of "All Unassigned".
In Access tab, click on Relay button, this will open Relay Restrictions dialog.
In relay computers list, add the loopback IP address i.e 127.0.0.1 and IP address of the Web server, so that they can pass/relay emails through the SMTP server.
source : SO

Related

Sending contact form data from docker container website to host mail server

I have a WordPress website in a Docker container which is running on linux server, the problem is I can't send the contact form data to my email address in the same server. According to my knowledge, WordPress uses mail() php function.
Server informations :
Debian 8
php 5.6
MTA: Postfix (dkim, spf, dmarc, ssl etc. done)
The server is working and sending emails since years, deliverability 10/10.
I am using the Outlook mobile app to access to my e-mails on my phone to this server, which means that the remote access to the SMTP server is working well. (port 587 on tls)
Docker container informations:
Ip address: 172.18.0.1
network mode: Bridge
Interface name: br-61b941dec29d
The website in the container is using WP 6.1.1 and the problem is (I know it's normal) that no emails are sent from the website, neither by clicking on WP reset password link, nor the contact form of the website, which was created with contact form 7 plugin.
Solutions tried:
I tried with a WP plugin that allows to set up external SMTP host, I set up the IP address of the host server, the port 587 and STARTTLS protocol, it did not work, the plugin has a "send test email" button, but at every try the plugin returns an error from the host server:
Connection failed. Error #2: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages:error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed
But since I can configure mobile app to access the SMTP server, and that the certificate (let's encrypt) is valid (I checked with a ssllabs.com) I don't understand this error.
I tried manually by editing the php.ini file in the container which is located at
/usr/local/etc/php/php.ini-production
SMTP = host_ip_address
smtp_port = 587 and then 25
sendmail_from = myaddress#domain.com
I also edited the /etc/postfix/main.cf by adding 172.18.0.0/24 to mynetworks the inet_interfaces was already set to "all"
mynetworks = xxx.xxx.xxx.0/24 [::ffff:127.0.0.0]/104 [::1]/128 172.18.0.0/24
inet_interfaces = all
None of these worked. I tried sending emails with a simple php script using mail() function, it failed with no error log, at least, the logs are not shown in docker logs.
What I'm looking for
Send the data from the contact form to an email address in this host server. It is not mandatory to use internet, since the container and the MTA are on the same host server.

How to prevent mail from Wordpress website from being flagged as spam on Exchange online server

I have a website; let's call it abc.com. It's e-mail is handled by Office365. I recently migrated it from a Sharepoint environment to a different webhost (GoDaddy). I have tried using the WP Mail SMTP plugin option to send e-mails, but it fails to send.
My settings are:
smtp: smtp.office365.com
port: 587
encryption: use TLS
authentication: use smtp
Sending fails with the error:
SMTP ERROR: Failed to connect to server: Connection refused (111)
Using the default wp mail with the settings below works to send to e-mail addresses outside the domain, but messages get flagged as spam on addresses within the domain.
header = 'From: '.get_option('blogname').' <wordpress#abc.com>'
I have e-mail routing set to Remote Mail Exchanger. I've tried adding the address wordpress#abc.com to Exchange's allowed list/whitelist, and I even tried adding the host IP to trusted IPs on the server - but it still doesn't work.
As far as I'm aware, GoDaddy do not let you send mail to external SMTP providers. If you're not able to choose another host (which I'd recommend if you can!), you'll need to use wp mail and send all mail to a local address at the same domain, hosted with GoDaddy.
If you wanted to, you could then set up an alias to send it elsewhere.
There's some more background on this over at wordpress.org, such as this thread and this thread.
EDIT
Just realised that the Postman SMTP plugin claims it can get around GoDaddy's filtering using HTTPS:
"Even hosts that block the standard SMTP ports, like GoDaddy or Bluehost, can't stop your email as Postman can deliver via HTTPS if it can't use SMTP."
So maybe give that plugin a go instead. :)
I ended up using the default wp mail.On the client o365 admin I added the email address to the whitelist. Made the mail rule priority over the default spam filter rule.I even went a step further to whitelist the IP but that's overkill I think.

biztalk server 2010 Error Routiing through SMTP send port

I have got a simple BizTalk Application in which there is only one schema and pipeline. I have simply add XML Validator in validate stage of pipeline.I have deployed this app in BizTalk Server 2010.
Now I have created a receive location which takes a XML file and set its receive pipeline which i have created. I have also marked "Enable routing for failed messaged" in receive port.
I have also created a SMTP send port and and configured it with mail server name and etc.
Receive port is working fine but send port is unable to send emails.
When i check "Track Service Instance" is shows an error "Transport failed to connect to the server".
Update: I am using Gmail SMTP server name in order to send e-mails and I am getting the error "The server rejected the sender address. The server response was: 530 5.7.0 Must issue a STARTTLS command first. ye1sm22267001pab.19 - gsmtp"
Where could be the problem? Any help will be appreciated
With that error in your update the problem is clear.
The Gmail server is expecting a SSL connection.
See SMTP TLS problem
The standard SMTP adapter does not support SSL/TLS connections.
You will need to write a custom adapter or purchase a third party
adapter to support SSL connections
http://www.nsoftware.com/products/biztalk/adapters/emails.aspx
Greg.Forsythe
EDIT: An alternative is to connect to a local SMTP server that doesn't require SSL/TLS and let it route the e-mails.
Are you running 32 bit or 64 bit? Is your tracking host in 32 bit or 64 bit? MIME/SMIME encoder pipeline can't run in 64 bit mode... are you using that?
http://msdn.microsoft.com/en-us/library/gg634591.aspx
"Transport failed to connect to the server"
This error message basically means the BizTalk SMTP adapter is unable to connect to the SMTP server or the server does not allow to send the e-mail.
Try connecting to the SMTP server with the telnet client (you may need to install this as an additional feature) or by configuring the proxy (available on the SMTP adapter and adapter defaults).
It might also be the case that you need to authenticate towards the SMTP server.
Also, some SMTP servers do not allow to send an e-mail from an unknown domain like "someone#notthenameofthecompany.com".
Hope this helps.

IIS 7 smtp cant send email

my application needs to send out emails to its users, but somehow I can't make it work. I have installed the SMTP server and in IIS I have set SMTP to use localhost, with port 25 without authentication. But when I try to send email, I am allways getting error
No connection could be made because the target machine actively refused it 127.0.0.1:25
When I choose the option to store email in directory, it works fine, so the problem isn't in my app. Why does this happen? The only thing I am thinking about, is if I need to have port 25 opened or not?
This would happen if you don't have an SMTP server listening on port 25.

IIS SMTP Server

I am trying to set up an SMTP server on a virtual private server. I have typically hosted applications with hosting companies in the past.
I am using SMPT on a website to send mail but need to configure IIS's SMTP Server to allow me to send the mail. I have a couple of questions around this:
1.What settings do I need to set to enable me to hit mail.myDomain.com and provide a user name and password for the mail to send?
2.What security issues do I need to be aware of and how do I lock down the SMTP server?
If you have an externally acessible SMTP server avalaible, just target it directly from your .NET code?
The <system.net> section in your config has some mail server settings you can use.

Resources