Go smtp send email - email

I am trying to send an email using Go. However I try to use my host custom mail servers which are the followings
So I am not quite sure what should I use over here. I am doing the following
auth := smtp.PlainAuth("", "noreply#icon-universe.com", "password", "mail.icon-universe.com")
log.Println(smtp.SendMail("mail.icon-universe.com:25", auth, "noreply#icon-universe.com", []string{"to#gmail.com"}, []byte("This is a simple test")))
However this would give me the following error
x509: certificate is valid for server.premierehost.net,
www.server.premierehost.net, not mail.icon-universe.com
So then I tried the following
auth := smtp.PlainAuth("", "noreply#icon-universe.com", "password", "server.premierehost.net")
log.Println(smtp.SendMail("server.premierehost.net:465", auth, "noreply#icon-universe.com", []string{"nakotoffana#gmail.com"}, []byte("thanks for loggin in")))
However this would just make my app go on an infinite loop...
Which connection details should I use?
Update
I decided to try go-mail and seems to work but not for #gmail
d := gomail.NewDialer("server.premierehost.net", 465, "noreply#icon-universe.com", "password")
m := gomail.NewMessage()
m.SetHeader("From", "noreply#icon-universe.com")
m.SetHeader("To", "carvajal#karmagameworks.com")
m.SetHeader("Subject", "Hello!")
m.SetBody("text/html", "Hello <b>Bob</b> and <i>Cora</i>!")
log.Println(d.DialAndSend(m))
This will work and the email will appear but sending to #gmail.com won't (the email will never arrive)

You appear to be using gomail correctly, but you should make sure the email account on gmail you are trying to send from has less secure apps turned on, otherwise this will never actually send.

firstly less secure apps must be turned on for your gmail account.
After that go to security section of your gmail account and in signing in google part, add a new app (create).
Then google will give a new app pass for that account.
Use that app password as your password
it will work

Related

Mailgun - Sending email with new smtp user (forbidden)

I have been configuring my mailgun project. The steps I've followed are:
Configure and verify my domain
Create mailing lists
Create routes for my business partners (i.e. victor#mycompany.com)
Create a Sending API Key
Create new SMTP users -> I tried to login with new SMTP accounts (for business partners) using Thunderbird, but didn't work. Is it possible to use mailgun with Thunderbird?
As the 4th step didn't work for me, I am configuring a postman workspace (imported from the Mailgun docs). The main problem I am expecting is that, in order to send a message, I have to use api (username) and SENDING_API_KEY (password) in the Authorization section...
I want to use the SMTP accounts I created (victor#mycompany.com) with the generated password, but I get the error Forbidden. Any ideas?
Note: I am using Basic Auth.

Flutter - No Long Receiving Firebase Emails [duplicate]

I am new to firebase and I am trying to handle firebase user authentication in React.js. I did manage to create users with email and passwords. But, now I would like to send the user an Email link to reset their password.
My code currently look like this.
// This line of code belongs to the top
import { auth } from '../firebaseConfig'
//This part goes under the React component
<p onClick={async () => {
try{
await sendPasswordResetEmail(auth, // My Email Id)
alert('Password reset link has been sent to your email')
}
catch(err){
alert(err)
}
}}
>Forgot your Password ?</p>
However, I do not get any error messages and I do get the alert message that says "Password reset link has been sent to your email." Unfortunately, I didn't receive any email. Note that I have given my own email id as the parameter for testing purposes.
firebaser here
Did you check your spam folder? We recently see a lot of the emails from Firebase Authentication ending up in the user's spam folder or being marked as spam in a system along the way. This is being tracked in this status message on the Firebase dashboard and in public issue #253291461.
To reduce the chances of the messages getting marked as spam, consider taking more control of the email delivery yourself.
As a first step, consider using a custom domain with your project. Email that comes from a custom domain has less chance of being marked as span.
As a second step, consider setting up your own SMTP server.) for delivering the email, so that the emails are not being delivered from Firebase's shared infrastructure anymore.
While these steps are more involved, they typically will drastically reduce the cases where the messages from Firebase Authentication are marked as spam.
Full Guide Based on Frank's Answer
Firstly create a new email account you can use to relay the Firebase emails through the SMTP server with. I personally chose Gmail, but I tested with Outlook and it also works.
You can now find an SMTP server host that will work for your scenario. If you're sending less than 1000 emails per month you can find free and reliable hosts. I chose SMTP2GO's free option.
Now you've found the SMTP host, add the email address you've chosen as a single sender email (note that if you do own a domain, you can alternatively use that to send emails).
Note that you will have to verify the email, usually by your host sending a link to the email's inbox. Make sure to check spam.
Once verified, navigate to where you host allows you to add SMTP Users and add a new user. This will allocate an SMTP username and password.
Navigate to the Firebase console, and choose the Authentication option from the sidebar (within the Build product category).
Go to Templates → SMTP Settings and enter the details of your SMTP server. The username and password fields are to be filled with the SMTP user login you created in the step above.
It is better to use TLS, but I believe SSL should work too but it is untested.
Click save, and you're all set up - but there may still be steps to perform depending on your email provider.
Provider Specific Steps
If the emails are being sent to an account managed by Google you will have no issues with your emails being quarantined by anti-spam policies and it will work immediately.
If you are using Outlook, you will have a different problem on your hands. Outlook's built in defender will most likely have auto-quarantined your email under multiple policies - that bit is important.
These policies are likely to be both spam and phish policies. If you unblock one of them, the other will catch it and re-quarantine.
Unblock both policies for the email address, and test. You can see the status of quarantined messages in Microsoft 365 Defender app under Review → Quarantine. Please note that you will need to be an administrator to add global allow policies to your email accounts.
If this still doesn't work it is likely that your company has an additional external filter (as mine did), and you will have to add the IP's manually to the Tenant Allow/Block Lists spoofed senders tab.

Unable to send email in go smtp library with gmail

I'm trying to send email through golang's smtp library using my gamil account.
It was working fine when I try to send emails a few days ago.
But suddenly today, I am not able to send email and the error shown is:
535 5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials h3sm2390100pji.16 - gsmtp
I'm sure that it succeed in signing into gmail because, 1. the username and password are correct, 2. When I push my code to the server and try to send the email again, my gmail account receive a "Critical Security Alert" email, saying that I have less secure access on, and I have selected that I have recognized the activity.
This shows that I have indeed able to login to gmail through my golang program, yet it was unable to send any email.
I have already turned on allow less secure access and I also have tried this https://accounts.google.com/DisplayUnlockCaptcha, and my password for gmail is "upper case letter + lower case letter + special symbols + numbers"
I have been stuck in this since I have tried all possible solution on the internet and still could not able to send email again using the golang program.
And the port I was using is 587.
By changing it to 465, it gives an error of EOF instead.

CACert add domain

I've registered at CACert to get a trusted certificate for my domain example.com, when I want to add the domain in the CACert control panel I have to select a email adress that is used for this domain:
The CACert FAQ states that there is currently no other way than getting an email at one of the specified email accounts. I currently don't have an email server running on my server to receive that email, but I tried to run one and it didn't work. Of course I could have read the documentations for the email server and try to get the server working, but is there a simpler way of receiving that email, because I just need that one email and it would be a realy big effort to run a full email server for this? Can I maybe redirect a email that is send at admin#example.com to my email adress at yahoo? With OS I'm flexible, I can use Windows or Linux, I just want to know the easiest way of receiving that adress.
Thanks in advance
No, there isn't another way of verfifying. But you easily setup an smtp server with postfix to receive the email

Script Sending mails with Gmail: Failed to authenticate on SMTP server

I am having some hard time getting my PHP script to send emails with a SMTP Gmail account. I am using PHP and Symfony2 SwiftMailer, but it seems that the problem lies with my Gmail account configuration. In my logs, I end up with the following error message:
"ERROR - Exception occurred while flushing email queue: Failed to authenticate on SMTP server with username "new.user.name#gmail.com" using 1 possible authenticators"
Luckily, I had another Gmail account working with another application, seemlessly. Rescuing these parameters (user and password) on my new box, eveything works just fine.
in parameters.yml I have (working fine):
parameters:
mailer_transport: gmail
mailer_host: ~
mailer_user: old.user.account#gmail.com
mailer_password: old-password
And here is the version giving auth error message:
parameters:
mailer_transport: gmail
mailer_host: ~
mailer_user: new.user.account#gmail.com
mailer_password: new-password
Needless to say I have checked, rechecked and checked yet again user and password.
I reviewed my Gmail account settings under "Forwarding and POP/IMAP" in my new account: I could find nothing about SMTP.
Searches made me aware some captcha policy may interfere with SMTP accounts. I read here that I should try to enter a captcha phrase, which I do here, and get the nice message:"Account access enabled", "Please try signing in to your Google account again from your new device or application."
Trying again. No luck.
All this is happening from my local dev environment (both OK mails, and NOT OK mails).
How I could get to use SMTP with a newly created Gmail Account ? Any idea ?
Actually, double-checking my inbox, I saw I received a mail from Google explaining someone was trying to enter my account. There, I found a link to the configuration parameter I was looking for:
https://www.google.com/settings/security/lesssecureapps
==> I just had to check: "Make my account less secure.", and was able to get mails sent.
In the mean time, I have found that Gmail SMTP service is getting pretty unrelyable and introduces captcha every now and again (here). I seems there is not much you can do about it. On the other hand, I read stronger passwords seem to help in some cases (here).
I must also say that with a newly created account, I was not able to get this working. Even unchecking the "make my account overly secure" option. It really looks like Gmail is phasing out its SMTP service.
UPDATE
I wanted to mention that there are some excellent and free (or very, very cheap for high volumes) alternatives for sending emails. For example, you could check Mandrill, SendGrid or Amazon SES, among others.
Using the link https://www.google.com/settings/security/lesssecureapps gave me the message: this setting is disabled by your administrator.
I had to go to admin.google.com and login with the same account details and look for the same setting there. Full url was https://admin.google.com/AdminHome#ServiceSettings/notab=1&service=securitysetting&subtab=lesssecureappsaccess
Then the first link worked, so also there I enabled less secure apps. Now I was able to use Gmails SMTP.
Maybe this helps someone: I had the same encounter with gmail, but in my case, when I logged into the gmail account that I configured in my code as SMTP mail sender user, I was greeted by a warning message saying that somebody tried to use my user and pass and that attempt was blocked (hence my error message). It asked me to confirm if that was me or not, so after I clicked the 'That was me' button and tried my code again all worked fine.
Making my account less secure helped me https://myaccount.google.com/lesssecureapps