Verify email existance or check the bounce back after sending it
My application send emails to clients, but now user wants to know whether mail exists or not before sending it, or give notification that email bounced back.
We are using SMTP server for sending emails and our application is in ASP.NET application.
Can someone help me with approach for solution, I can see multiple things on Google but nothing is really working out.
See also questions close to this topic
-
Huge amount of logon attempts when loading a page (without cache)
I notice in the Performance Monitor of Windows Server 2012 that there are spikes in logon attempts per second under Web Service -> Logon Attempts/sec. These spikes go from about 0 to 50.
I've traced this down to a page refresh. Loading a page with no cache that is. An average page load does about 50 requests (images, scripts, etc). Now apparently these 50 requests are shown as logon attempts.
Is this normal?
Note that this page does not require the visitor to be logged in.
-
Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler[3\
When warn: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[60]
Storing keys in a directory '/root/.aspnet/DataProtection-Keys' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed.
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
No XML encryptor configured. Key {e43b756a-2818-4898-8730-5e8e0f230be7} may be persisted to storage in unencrypted form.
info: IdentityServer4.Startup[0]
Starting IdentityServer4 version 4.1.1+cebd52f5bc61bdefc262fd20739d4d087c6f961f
info: IdentityServer4.Startup[0]
You are using the in-memory version of the persisted grant store. This will store consent decisions, authorization codes, refresh and reference tokens in memory only. If you are using any of those features in production, you want to switch to a different store implementation.
info: IdentityServer4.Startup[0]
Using the default authentication scheme Identity.Application for IdentityServer
info: Microsoft.Hosting.Lifetime[0]
Now listening on: https://[::]:8081
info: Microsoft.Hosting.Lifetime[0]
Now listening on: http://[::]:8080
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
Content root path: /app
info: IdentityServer4.Hosting.IdentityServerMiddleware[0]
Invoking IdentityServer endpoint: IdentityServer4.Endpoints.TokenEndpoint for /connect/token
info: IdentityServer4.AspNetIdentity.ResourceOwnerPasswordValidator[0]
Credentials validated for username: muthu
info: IdentityServer4.Validation.TokenRequestValidator[0]
Token request validation success, {
"ClientId": "sdgfsdsgsdg",
"ClientName": "Swagger UI",
"GrantType": "password",
"Scopes": "api",
"AuthorizationCode": "********",
"RefreshToken": "********",
"UserName": "sample",
"Raw": {
"grant_type": "password",
"username": "sample",
"password": "REDACTED"
}
}
fail: Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler[3]
Exception occurred while processing message.
System.InvalidOperationException: IDX20803: Unable to obtain configuration from: 'http://*:8080/.well-known/openid-configuration'.
---> System.IO.IOException: IDX20804: Unable to retrieve document from: 'http://*:8080/.well-known/openid-configuration'.
---> System.UriFormatException: Invalid URI: The hostname could not be parsed.
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
at System.Uri..ctor(String uriString, UriKind uriKind)
at Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.GetDocumentAsync(String address, CancellationToken cancel)
--- End of inner exception stack trace ---
at Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.GetDocumentAsync(String address, CancellationToken cancel)
at Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfigurationRetriever.GetAsync(String address, IDocumentRetriever retriever, CancellationToken cancel)
at Microsoft.IdentityModel.Protocols.ConfigurationManager`1.GetConfigurationAsync(CancellationToken cancel)
--- End of inner exception stack trace ---
at Microsoft.IdentityModel.Protocols.ConfigurationManager`1.GetConfigurationAsync(CancellationToken cancel)
at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync()
fail: IdentityServer4.AccessTokenValidation.IdentityServerAuthenticationHandler[0]
IDX20803: Unable to obtain configuration from: 'http://*:8080/.well-known/openid-configuration'.
System.InvalidOperationException: IDX20803: Unable to obtain configuration from: 'http://*:8080/.well-known/openid-configuration'.
---> System.IO.IOException: IDX20804: Unable to retrieve document from: 'http://*:8080/.well-known/openid-configuration'.
---> System.UriFormatException: Invalid URI: The hostname could not be parsed.
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
at System.Uri..ctor(String uriString, UriKind uriKind)
at Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.GetDocumentAsync(String address, CancellationToken cancel)
--- End of inner exception stack trace ---
at Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.GetDocumentAsync(String address, CancellationToken cancel)
at Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfigurationRetriever.GetAsync(String address, IDocumentRetriever retriever, CancellationToken cancel)
at Microsoft.IdentityModel.Protocols.ConfigurationManager`1.GetConfigurationAsync(CancellationToken cancel)
--- End of inner exception stack trace ---
at Microsoft.IdentityModel.Protocols.ConfigurationManager`1.GetConfigurationAsync(CancellationToken cancel)
at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync()
at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync()
at Microsoft.AspNetCore.Authentication.AuthenticationHandler`1.AuthenticateAsync()
at Microsoft.AspNetCore.Authentication.AuthenticationService.AuthenticateAsync(HttpContext context, String scheme)
at IdentityServer4.AccessTokenValidation.IdentityServerAuthenticationHandler.HandleAuthenticateAsync()
info: IdentityServer4.AccessTokenValidation.IdentityServerAuthenticationHandler[7]
Bearer was not authenticated. Failure message: IDX20803: Unable to obtain configuration from: 'http://*:8080/.well-known/openid-configuration'.
info: IdentityServer4.AccessTokenValidation.IdentityServerAuthenticationHandler[12]
AuthenticationScheme: Bearer was challenged.
-
ASP.NET using return RedirectToAction(" ", " ") how to use this to redirect to a cshtml
I can not find a useable tutorial that explains how to redirect using REdirectToAction. can someone share a link that that explains ALL the steps needed to use this? I think I am having a hard time understanding how the parameters are given can find an HTML file with a model in the parameter? or is it a controller? I am very lost on how they communicate. please someone if you can help.
-
Sending email with node using nodemailer on digitalocean server
I am using the following function to send an email with node
Mail.sendMail({ to: `${obj.nome} <${obj.email}>`, subject: 'Process Status', template: 'processStatus', context: { nome: obj.name, processo: processNumber, descricao_status: req.body.status, }, });
those are my SMTP settings in my .env file
MAIL_HOST=email-ssl.com.br MAIL_PORT=465:1 MAIL_USER= ... MAIL_PASS= ...
when I test sending e-mail using my machine, locally, I can send e-mails correctly, but when using direct sending on the server, I'm using digitalocean, it doesn't work, does anyone have any idea what can to be ? or something that I can check?
another question is, why do i have to use this: 1? already tested without the same and does not work
-
stream_socket_enable_crypto(): Peer certificate CN=`hv22svg069.neubox.net' did not match expected CN=`smtp.sendgrid.net'
I'm developing a web application with laravel and i send emails with sengrid using sociallite driver, everything works as i expect in localhost, but i deployed my application on a shared host and when i try to send an email i get the following error:
stream_socket_enable_crypto(): Peer certificate CN=`hv22svg069.neubox.net' did not match expected CN=`smtp.sendgrid.net'
I've been reading similar questions here but everything is related to disable smtp restrictions or disable encryption which may cause security issues and is something i can't do because is an application for a customer.
I found a certificate in the sengrid page:
Certificate verification failed for smtp.sendgrid.net
but i don't know if is what i need because i don't know how to exactly setting it on the shared host's cPanel.
Any help is welcome. Regards!
-
Python email sending bot for discord
I have a bot that should send certain amount of emails to specified email addresses. I have code for GMail SMTP server but when I change SMTP from google to smtp2go.net it says:
2021-03-02T19:29:30.985313+00:00 app[worker.1]: [19:29:30] [Command used] - Starki#6821: !email 1 mek@mailinator.com test 2021-03-02T19:29:31.193965+00:00 app[worker.1]: Ignoring exception in command email: 2021-03-02T19:29:31.194255+00:00 app[worker.1]: Traceback (most recent call last): 2021-03-02T19:29:31.194340+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/discord/ext/commands/core.py", line 85, in wrapped 2021-03-02T19:29:31.194341+00:00 app[worker.1]: ret = await coro(*args, **kwargs) 2021-03-02T19:29:31.194410+00:00 app[worker.1]: File "Emails.py", line 76, in email 2021-03-02T19:29:31.194411+00:00 app[worker.1]: mail = smtplib.SMTP('mail.smtp2go.net',2525) 2021-03-02T19:29:31.194411+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/smtplib.py", line 251, in __init__ 2021-03-02T19:29:31.194411+00:00 app[worker.1]: (code, msg) = self.connect(host, port) 2021-03-02T19:29:31.194449+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/smtplib.py", line 336, in connect 2021-03-02T19:29:31.194449+00:00 app[worker.1]: self.sock = self._get_socket(host, port, self.timeout) 2021-03-02T19:29:31.194480+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/smtplib.py", line 307, in _get_socket 2021-03-02T19:29:31.194481+00:00 app[worker.1]: self.source_address) 2021-03-02T19:29:31.194533+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/socket.py", line 704, in create_connection 2021-03-02T19:29:31.194534+00:00 app[worker.1]: for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2021-03-02T19:29:31.194578+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/socket.py", line 745, in getaddrinfo 2021-03-02T19:29:31.194578+00:00 app[worker.1]: for res in _socket.getaddrinfo(host, port, family, type, proto, flags): 2021-03-02T19:29:31.194666+00:00 app[worker.1]: socket.gaierror: [Errno -2] Name or service not known
Here is my full code:
from discord.ext import commands import time import asyncio import smtplib import datetime from configparser import ConfigParser import os import sys from colorama import Fore, init init(convert=True) os.system("title EmailSpammer!") config = ConfigParser() config.read('setup.ini') emale = config.get('SETTINGS', 'email') pas = config.get('SETTINGS', 'password') token = config.get('SETTINGS', 'bottoken') def type(words): words for char in words: time.sleep(0.001) sys.stdout.write(char) sys.stdout.flush() time.sleep(0.01) bot = commands.Bot(command_prefix='!', description="peepee") bot.remove_command("help") @bot.event async def on_ready(): await bot.change_presence(activity = discord.Streaming(name="@BadRabbit001", url="https://www.twitch.tv/gmail")) type(f""""{Fore.RED} ███████╗███╗ ███╗ █████╗ ██╗██╗ ██╔════╝████╗ ████║██╔══██╗██║██║ █████╗ ██╔████╔██║███████║██║██║ ██╔══╝ ██║╚██╔╝██║██╔══██║██║██║ ███████╗██║ ╚═╝ ██║██║ ██║██║███████╗ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝╚══════╝ ███████╗██████╗ █████╗ ███╗ ███╗██╗ ██╔════╝██╔══██╗██╔══██╗████╗ ████║██║ ███████╗██████╔╝███████║██╔████╔██║██║ ╚════██║██╔═══╝ ██╔══██║██║╚██╔╝██║╚═╝ ███████║██║ ██║ ██║██║ ╚═╝ ██║██╗ ╚══════╝╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ """) count = 10 #penusssss @bot.command() async def email(ctx,count=None,bomb_email=None,*,message=None): if count == None or bomb_email == None or message == None: await ctx.send("Format - !email [count] [email] [message] - e.g !email 10 email@email.com hii!") else: x = int(count) if x > 100: await ctx.send("`That's a lot of spam. Do 100 or less! Bruh`") else: currentDT = datetime.datetime.now() hour = str(currentDT.hour) minute = str(currentDT.minute) second = str(currentDT.second) print(f"{Fore.RED}[{Fore.WHITE}{hour}:{minute}:{second}{Fore.RED}]{Fore.GREEN} [Command used] - {ctx.author.name}#{ctx.author.discriminator}:{Fore.RESET} !email {count} {bomb_email} {message}") counting = int(0) embed=discord.Embed(title=f"{counting}/{count}", url="https://shoppy.gg/@BadRabbit001", color=0xff0000) embed.set_author(name="Email sent!", url="https://shoppy.gg/@BadRabbit001") embed.set_thumbnail(url="https://cdn.iconscout.com/icon/free/png-256/gmail-30-722694.png") embed.add_field(name=f'Sending "{message}"', value=f'**to {bomb_email}**', inline=False) embed.set_footer(text=f"Requested by {ctx.author.name}#{ctx.author.discriminator}") msg = await ctx.send(embed=embed) for i in range(x): mail = smtplib.SMTP('mail.smtp2go.net',2525) mail.ehlo() mail.starttls() mail.login(emale,pas) mail.sendmail(emale,bomb_email,message) mail.close() currentDT = datetime.datetime.now() hour = str(currentDT.hour) minute = str(currentDT.minute) second = str(currentDT.second) print(f"{Fore.RED}[{Fore.WHITE}{hour}:{minute}:{second}{Fore.RED}]{Fore.GREEN} Message Sent:{Fore.RESET} {message} {Fore.GREEN}To {Fore.RESET}{bomb_email}") counting = counting + 1 embed=discord.Embed(title=f"{counting}/{count}", url="https://github.com/kieronia", color=0xff0000) embed.set_author(name="Email sent!", url="https://shoppy.gg/@BadRabbit001") embed.set_thumbnail(url="https://cdn.iconscout.com/icon/free/png-256/gmail-30-722694.png") embed.add_field(name=f'Sending "{message}"', value=f'**to {bomb_email}**', inline=False) embed.set_footer(text=f"Requested by {ctx.author.name}#{ctx.author.discriminator}") await msg.edit(embed=embed) embed=discord.Embed(title="Check my Shoppy for more cool stuff!", url="https://shoppy.gg/@BadRabbit001", color=0xff0000) embed.set_author(name="Done spamming!", url="https://shoppy.gg/@BadRabbit001") embed.set_thumbnail(url="https://cdn.iconscout.com/icon/free/png-256/gmail-30-722694.png") await msg.edit(embed=embed) bot.run(os.getenv('CODE'))```
-
How can I specify the outgoing mail server in a script that uses the PHP mail() function?
I'm using a PHP mail script that I purchased a license for, called FormToEmail (I suspect the recent product with this name is different to my older one). It uses the PHP mail() function to send emails, but they're being sent from my host's default web server. I want the script to send emails using my outgoing mail server instead. I've tried the following to no avail - hopefully it at least helps illustrate what I'm trying to achieve:
$mail->Host="mail.mydomain.com"; $mail->SMTPAuth = true; $mail->Username= "mymailbox@mydomain.com"; $mail->Password= "mypassword"; $mail->SMTPSecure="ssl"; $mail->Port = 465;
-
Error in subject with special characters sending Email SMPT by openssl and s_client
I've a bash script in Linux for sent email. I'm using SMTP by openssl and s_client.
It's multilanguage, so sometimes there are special characters (è, à...), that are shown correctly in the body but not in subject for any Microsoft based (Outlook, Hotmail...).
Using openssl
I use the following command:
openssl s_client -crlf -quiet -starttls smtp -connect <smarhost.server>:<port> < <configuration_and_body_file>
The
<configuration_and_body_file>
is a plain text file which contains the connection protocol and the data for the email as followsMAIL FROM: example@example.com RCPT TO: emailto@emailto.com DATA From: Sender <example@example.com> To: emailto@emailto.com Subject: accès à ... Some text with special characters as (è, à, ë...) . QUIT
If I send it to a Gmail or any different than Microsoft (Outloik, Hotmail) the subject and body are right. But when the receiptent is working with Hotmail or Outlook the special characters are wrong decoded as
Ã
or others.The output of the command is as follows:
verify return:1 depth=1 C = BE, O = GlobalSign nv-sa, CN = GlobalSign GCC R3 DV TLS CA 2020 verify return:1 depth=0 CN = *.<foodomain> verify return:1 250 DSN 250-gefwml03e.<foodomain> 250-PIPELINING 250-SIZE 31457280 250-ETRN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN 250 2.1.0 Ok 250 2.1.5 Ok 354 End data with <CR><LF>.<CR><LF> 250 2.0.0 Ok: queued as 27C77671AE7_3E83FBF 221 2.0.0 Bye
Maybe the 250-8BITMIME in this case how can I change it? I tried adding -utf8 but it doesn't works.
Using mailx and postfix
I've install mailutils package and configure postfix. Adding the smarthost to
relayhost
and settinginet_interfaces = loopback-only
I've sent the email using following commmand:
echo "Some text with special characters è à" | mailx -s "From: Some text with special characters è à" -a "Sender <norepley@sender.com>" some_email@example.com
I get and error because of the UTF8 from the smarthost:
status=bounced (SMTPUTF8 is required, but was not offered by host <smarthost>
I've added to postfix the parameter to avoid that error
smtputf8_enable = no
If I execute the last mail command to send the email, the email is sent but the special characters are wrong printed in Microsoft emails based but are right in Gmail.
As workaround I've created a fail with the body that contains special characters too. I send as:
mailx -s "Some text with special characters è à" -a "From: Sender <norepley@sender.com>" some_email@example.com < body.txt
This email is shown with the special characters in the right way for the body in all email accounts but Subject is still wrong in Microsoft based ones.
Some clue about how can force the subject to be also printed in the right way for Microsoft emails based on?
Thanks in advance
-
How to connect given IP with SMTP server in PHP
Trying to validate if an Email is valid or not using SMTP and PHP. Now it works fine but I need some changes.
my primary IP address used to connect automatically with SMTP but I want to connect my second IP of the same server with SMTP.
It is possible? If yes how? function validate($emails = false, $sender = false) {
$results = array(); foreach($this->domains as $domain=>$users) {
$mxs = array(); $this->domain = $domain; list($hosts, $mxweights) = $this->queryMX($domain); for($n=0; $n < count($hosts); $n++){ $mxs[$hosts[$n]] = $mxweights[$n]; } asort($mxs); $mxs[$this->domain] = 0;
$this->debug(print_r($mxs, 1));
$timeout = $this->max_conn_time;while(list($host) = each($mxs)) { $this->debug("try $host:$this->port\n"); if ($this->sock = fsockopen($host, $this->port, $errno, $errstr, (float) $timeout)) { stream_set_timeout($this->sock, $this->max_read_time); break; } } if ($this->sock) { $reply = fread($this->sock, 2082); $this->debug("<<<\n$reply"); preg_match('/^([0-9]{3}) /ims', $reply, $matches); $code = isset($matches[1]) ? $matches[1] : ''; if($code != '220') { foreach($users as $user) { $results[$user.'@'.$domain] = false; } continue; } $this->send("HELO ".$this->from_domain); $this->send("MAIL FROM: <".$this->from_user.'@'.$this->from_domain.">"); foreach($users as $user) { $reply = $this->send("RCPT TO: <".$user.'@'.$domain.">"); $this->send("DATA"); $this->send('From: <'.$this->from_user.'@'.$this->from_domain.'>'); $reply = $this->send("."); preg_match('/^([0-9]{3}) /ims', $reply, $matches); $code = isset($matches[1]) ? $matches[1] : ''; } $this->send("quit"); fclose($this->sock); } } return $results; }
-
How can I add email messages to my maildir so I can test my bounce processor?
My email accounts are setup to use the maildir format. I also have a 3rd party email processing API called BoogieTools. I want to simulate various types of bounce emails to verify the API handles them correctly. To do that, I would like to drag/drop these various types of email from my iMac desktop into the Transmit app I use for SFTP, which would put them on the server in the right mail account or directory. But I'm kinda new too Postfix, email formats, and not a big fan of the command line, etc. One email file name I managed to copy down was in this format:
1598072705.M835079P504.exampleDomain.com,S=5647,W=5757/2,S
Does anyone know of a good list of example bounce emails online? I would like to copy them, change the file name so it contains my relevant domain, put them on my sever, and hope the bounce processor will properly act on them. I hope I'm making sense here.
Unfortunately BoogieTools does not have good customer support, that is why I'm asking here.
Thank you.
-
Bounce Management - distinction of hardbounces and softbounces
I have to take care of the softbounce and hardbounce detection.
My Problem is that, different providers send back different answers
Example:
Statuscode: 550 - 5.1.1 can mean that the mailbox is full or that the account does not exist.
in case of mailbox full it would be a softbounce in case of account does not exist it would be a hardbounce
My approach is to add a rules like If status 550 and mailbox full = softbounce If status 550 and account does not exist = Hardbounce
My idear is to slove this problem with RegEx and build a set of rules. This solution doesn't seem right to me and very costly because every provider can give a different answer and I would have to react to all answers.
Now to the question: Do you guys have a better idea or solution for my problem?
I am very grateful for ideas or solutions.