Jump to content

Sending mails error


Recommended Posts

Hey guys, I am currently trying to send a mail with an AutoIT script

Code:

#include <Inet.au3>
#include <MsgBoxConstants.au3>

Local $s_SmtpServer = "smtp.gmail.com"
Local $s_FromName = "TEST"
Local $s_FromAddress = "*@gmail.com"
Local $s_ToAddress = "*@gmail.com"
Local $s_Subject = "TEST"
Local $as_Body[2]
$as_Body[0] = "Testmail"
$as_Body[1] = "Second Line"
Local $iResponse = _INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body)
Local $iErr = @error
If $iResponse = 1 Then
    MsgBox($MB_SYSTEMMODAL, "Success!", "Mail sent")
Else
    MsgBox($MB_SYSTEMMODAL, "Error!", "Mail failed with error code " & $iErr)
EndIf

But I am getting this error:

0PLOc.jpg

What am I doing wrong?

Link to comment
Share on other sites

  • Developers

Gmail is using secure SMTP so the regular  _INetSmtpMail() will not work. Search the forum  for  _INetSmtpMailCom() which will work.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

3 hours ago, Jos said:

Gmail is using secure SMTP so the regular  _INetSmtpMail() will not work. Search the forum  for  _INetSmtpMailCom() which will work.

Jos

Thanks for you reply!

I tried to use your _INetSmtpMail() script form here: 

Now I am getting this error msg;

RrOWc.jpg

I have edited only this part:

;##################################
; Variables
;##################################
$SmtpServer = "smtp.gmail.com"              ; address for the smtp-server to use - REQUIRED
$FromName = "Test"                      ; name from who the email was sent
$FromAddress = "*@gmail.com" ; address from where the mail should come
$ToAddress = "*@gmail.com"   ; destination address of the email - REQUIRED
$Subject = "TESTMAIL"                   ; subject from the email - can be anything you want it to be
$Body = "TESTMAIL"                              ; the messagebody from the mail - can be left blank but then you get a blank mail
$AttachFiles = ""                       ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed
$CcAddress = ""       ; address for cc - leave blank if not needed
$BccAddress = ""     ; address for bcc - leave blank if not needed
$Importance = "Normal"                  ; Send message priority: "High", "Normal", "Low"
$Username = "*@gmail.com"                    ; username for the account used from where the mail gets sent - REQUIRED
$Password = "*"                  ; password for the account used from where the mail gets sent - REQUIRED
$IPPort = 465                            ; port used for sending the mail
$ssl = 1                                ; enables/disables secure socket layer sending - put to 1 if using httpS
;~ $IPPort=465                          ; GMAIL port used for sending the mail
;~ $ssl=1                               ; GMAILenables/disables secure socket layer sending - put to 1 if using httpS

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...