Problem configuring mail for local Blynk server

I’m setting up a local Blynk Server on my Macbook Pro running Catalina 10.15.7. I’m able to successfully install with -serverProperties specified. When I try to add -mailProperties, however, I get an error message.

Here’s the command line to start the server (after a “cd” to the directory containing all files):

java -jar server-0.41.14-java8.jar -dataFolder server_data -serverConfig server.properties -mailConfig mail.properties

Here’s the mail.properties file

mail.smtp.auth=true
mail.smtp.starttls.enable=true
mail.smtp.host=smtp.gmail.com
mail.smtp.port=587
mail.smtp.username=MyGmailAccount
mail.smtp.password=MyGmailPassword

and here’s the output:

Exception in thread "main" java.lang.NullPointerException: Cannot invoke "String.length()" because "s" is null
	at javax.mail.internet.InternetAddress.parse(InternetAddress.java:793)
	at javax.mail.internet.InternetAddress.parse(InternetAddress.java:752)
	at javax.mail.internet.InternetAddress.<init>(InternetAddress.java:119)
	at cc.blynk.server.notifications.mail.GMailClient.<init>(GMailClient.java:45)
	at cc.blynk.server.notifications.mail.MailWrapper.<init>(MailWrapper.java:28)
	at cc.blynk.server.Holder.<init>(Holder.java:136)
	at cc.blynk.server.launcher.ServerLauncher.start(ServerLauncher.java:95)
	at cc.blynk.server.launcher.ServerLauncher.main(ServerLauncher.java:73)

Can someone help me with this? Thanks!

The Blynk server GitHub page doesn’t mention specifying the path to the mail.properties file in the startup command. It says…

Create file mail.properties within same folder where server.jar is.

https://github.com/blynkkk/blynk-server#enabling-mail-on-local-server

Pete.

Right. And that’s exactly what I did Pete. Here’s the “ls -p” for that directory.

logs/				server-0.41.14-java8.jar	server_data/
mail.properties			server.properties		static/

So what happens if you start your server with just…

java -jar server-0.41.14-java8.jar -dataFolder server_data -serverConfig server.properties

Pete.

Works just fine; able to add a new user from the app (although I’ve had problems accessing the admin console, as I described in a separate post). No problems until I add the -mailConfig flag. Then, blooooeee!

The point I’m making is that flag isn’t in the documentation, and isn’t required to be able to send emails from the app.

Pete.

Hi Pete, The flag IS in the documentation. Looking here: https://github.com/blynkkk/blynk-server#blynk-server I see:

Advanced local server setup

For more flexibility you can extend server with more options by creating server.properties file in same folder as server.jar . Example could be found here. You could also specify any path to server.properties file via command line argument -serverConfig . You can do the same with mail.properties via -mailConfig and sms.properties via -smsConfig .

I’m trying to set this up, because I want the server to send me email with the auth token when a new project is created (rather than trying to transcribe it off my iPhone screen into my sketch). If there’s a better way (or any other way!!) to do this, please let me know! Thanks.

I’m seeing now that I didn’t read this carefully enough. Going to do some more testing, and will get back with results

But this is t what you’re doing is it? You aren’t specifying a path to these files in your startup command.

If the files in question are in the same location as the .jar file then you don’t need to mention them in the startup command, they will be found automatically. If you want to put them somewhere else then you need to include this in the startup command and specify the path to these files

My server startup command looks like this:

java -jar /home/pi/server-0.41.13.jar -dataFolder /home/pi/Blynk &

and my /home/pi folder looks like this:

Pete.

Thanks, Pete. I figured out what you were trying to tell me just before you sent that informative note; thank you. The server is starting up just fine without the extra flags. And the app tells me that an email is sent when I create a new project. However, in the server log I’m seeing:

3:03:43.113 ERROR- Error sending email auth token to user : elbyman1@gmail.com. Error: 530-5.7.0 Authentication Required. Learn more at
530 5.7.0  https://support.google.com/mail/?p=WantAuthError z14sm80344oot.5 - gsmtp

I tried following that link, but it seems to be dead. I did a bit of Googling, and found this can be due to 2-part authentication in Gmail, but I checked, and I don’t have 2-part authentication turned on. I did activate “Allow less secure apps”. Also double-checked the password that I entered in mail.properties, and it looks fine.
Any thoughts on what this problem might be?

Not sure to be honest.

My mail properties file has these additional lines:

mail.smtp.timeout=120000
mail.smtp.connectiontimeout=30000

not sure if that would help?
I think you may have to restart the server for any changes to take effect - this is certainly the case with server.properties

I’m not really a Gmail user myself, although I do have an account that I set up to be able to access some Google functionality and that I use occasionally for a few odd things. Like everything, I have two-factor authorisation configured for this account.
However, I created a new Gmail account and configured the “Allow less secure apps” option and no two-factor authorisation and this is used solely for Blynk emails.

Oh, and don’t try editing these files through the Blynk admin console - changes aren’t saved!

Pete.

And this might be worth trying too,

Pete.

SOLVED. After a lot of poking around, I found someone with a similar problem describe dealing with markup in their mail.properties file. I had the same problem! The TextEditor program I was using on the Mac was hiding a bunch of markup. When I did a “cat” in the terminal, I could see it. The fix was to delete the file, then re-create it by typing “cat > mail.properties” in the terminal, type in all the correct lines, then to complete the file. I did the same for server.properties, and everything is working great now :slight_smile: Thanks very much for your help with this, Pete.

1 Like