5

I want to send a mail from a Windows batch file. Here is my code:

blat test.log -server smtp.gmx.com -to dest@gmail.com -f address@gmail.com -s "test mail" -u "address@gmail.com" -pw "password" -debug -log envois-mails.log -timestamp 

Here is the error I get:

2014.07.23 14:07:26 (Wed): <<<getline<<< 535 Authentication credentials invalid
2014.07.23 14:07:26 (Wed): The SMTP server did not accept Auth PLAIN value.
Are your login userid and password correct?
2014.07.23 14:07:26 (Wed): >>>putline>>> AUTH LOGIN
2014.07.23 14:07:26 (Wed): <<<getline<<< 334 VXNlcm5hbWU6
2014.07.23 14:07:26 (Wed): >>>putline>>> b3Vzcy56YWltQGdtYWlsLmNvbQ==
2014.07.23 14:07:26 (Wed): <<<getline<<< 334 UGFzc3dvcmQ6
2014.07.23 14:07:26 (Wed): >>>putline>>> aG90bWFpbGhvdG1haWw=
2014.07.23 14:07:26 (Wed): <<<getline<<< 535 Authentication credentials invalid
2014.07.23 14:07:26 (Wed): The SMTP server did not accept Auth LOGIN PASSWD value.
2014.07.23 14:07:26 (Wed): >>>putline>>> QUIT
2014.07.23 14:07:26 (Wed): <<<getline<<< 221 gmx.com Service closing transmission channel

Do you have you any idea about how to resolve the problem?

I am using Blat to send the emails

  • It appears your authentication credentials are not valid based on the error. What are you using to actually send the emails beause you don't indicate that. – Ramhound Jul 23 '14 at 12:43
  • i'm using blat, and i'm sure that authentication credentials are valid – user2480100 Jul 23 '14 at 13:03
  • The server allows SMTP connections. What restrictions does it place on those connections? – Ramhound Jul 23 '14 at 13:57
  • honestly i do not know! I know nothing about network – user2480100 Jul 23 '14 at 15:19
  • 2
    The SMTP server did not accept Auth PLAIN value guessing servers expects SSL/TLS connection – Sathyajith Bhat Jul 23 '14 at 17:48
2

I think you can easily get it done through Powershell.

Follow these Steps:

Step 1 - Open CMD (Run as Administrator)
Step 2 - Type Powershell (Hit Enter)
Step 3 - Copy the below code in notepad first

$EmailFrom = “Your email Address” $EmailTo = “Recipients email Address”
$Subject = “The subject of your email”
$Body = “This is just a test mail to verify the working of CMD”
$SMTPServer = “smtp.gmail.com”
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential(“username”, “password”);
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)

Step 4 - change Your Email address to sender's email
Step 5 - Change Recipients Email Address
Step 6 - Replace Subject and body text according to your need
Step 7 - Replace "username" and "password" with your credentials.
Step 8 - Copy the above code and paste in windows Powershell.

This will surely work for gmail. For others you may try changing the SMTP server and client details.

  • I can not switch to Powershell, because this sends of emails is just a small part of my script, do you another idea ? – user2480100 Jul 24 '14 at 8:26
1

As others have guessed, this is because of Gmail requiring TLS/SSL connection and from what I can see Blat does not support that.

I worked around it with stunnel which works really well. It sets up a TLS/SSL tunnel (to gmail SMTP in this case) which non-TLS/SSL enabled apps can use to send emails through. I also use it to email (via gmail) from a couple of other apps that don't support TLS/SSL. TBH I don't recall the config but it was pretty straight forward.

You still use your gmail credentials, but substitute your stunnel server (localhost? - I have it set up on it's own Linux server and use it's IP but it's cross platform so I guess it could use localhost on Windows).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.