Jump to content

Smtp Mailer That Supports Html And Attachments.


Jos
 Share

Recommended Posts

  • Developers

I have one question, is the $s_FromAddress variable really necessary? I tried putting a couple different values in there to see if i could spoof an email address, but it always shows the email address that I am really sending from... So, is there really any need to have that there? I'm still learning, so just wondering about that. I am using gmail, so could it have something to do with their email service?

The $s_FromAddress variable needs to contain a valid from EMail address supported by your provider. I need to see the code you use to see why it stays the same ..

:)

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

The $s_FromAddress variable needs to contain a valid from EMail address supported by your provider. I need to see the code you use to see why it stays the same ..

:whistle:

Yes, this does happen. At least with Gmail. I put gibberish in the $s_FromAddress variable and it send it fine as long as i had a valid user/pass.

Doesn't matter IMO, I'm just glad i finally got this script to work.

Link to comment
Share on other sites

  • Developers

Anyone know how you could have multiple lines in the Body? I'm trying to create a GUI for sending the mail but I can only type one single straight line for the Body?

As far as I know @CRLF's in normal text message and <b> in HTML messages will generate a newline in the message.

:whistle:

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 weeks later...

This code works with gmail and your local smtp server...

#include <GUIConstants.au3>
#include<File.au3>
#include <String.au3>
opt("TrayMenuMode", 1)
opt("TrayOnEventMode", 1)

AdlibEnable("ReduceMemory", 5000)
Func ReduceMemory($i_PID = -1)
    Local $ai_R = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
    Return $ai_R[0]
EndFunc

Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")

$GUI = GUICreate("Send Email", 350, 360, -1, -1)
$Smtp = GUICtrlCreateLabel("Smtp :",  5, 9, 70)
GUICtrlSetFont($Smtp, 14)
$From = GUICtrlCreateLabel("Van :",  5, 39, 70)
GUICtrlSetFont($From, 14)
$To = GUICtrlCreateLabel("Naar :",  5, 69, 70)
GUICtrlSetFont($To, 14)
$Name = GUICtrlCreateLabel("Naam :",  5, 99, 70)
GUICtrlSetFont($Name, 14)
$Attachlabel = GUICtrlCreateLabel("Attatch:", 5, 129, 70)
GUICtrlSetFont($Attachlabel, 14)
$Subjectlabel = GUICtrlCreateLabel("Subject :",  5, 159, 70)
GUICtrlSetFont($Subjectlabel, 14)
$Usernamelabel = GUICtrlCreateLabel("User :",  5, 189, 70)
GUICtrlSetFont($Usernamelabel, 14)
$Passwordlabel = GUICtrlCreateLabel("Pass :",  5, 219, 70)
GUICtrlSetFont($Passwordlabel, 14)
$Bodylabel = GUICtrlCreateLabel("Body :",  5, 262, 70)
GUICtrlSetFont($Bodylabel, 14)

$mailserverin = GUICtrlCreateInput("", 83, 5, 262, 28)
GUICtrlSetFont($mailserverin, 14)
$youremailin = GUICtrlCreateInput("", 83, 35, 262, 28)
GUICtrlSetFont($youremailin, 14)
$toaddressin = GUICtrlCreateInput("", 83, 65, 262, 28)
GUICtrlSetFont($toaddressin, 14)
$yournamein = GUICtrlCreateInput("", 83, 95, 262, 28)
GUICtrlSetFont($yournamein, 14)
$attatchin = GUICtrlCreateInput("", 83, 125, 192, 28)
GUICtrlSetFont($attatchin, 14)
$subjectin = GUICtrlCreateInput("", 83, 155, 262, 28)
GUICtrlSetFont($subjectin, 14)
$body = GuiCtrlCreateEdit("", 83, 245, 262, 75, 0x50231104)
GUICtrlSetFont($body, 14)
$usernamein = GUICtrlCreateInput("", 83, 185, 262, 28)
GUICtrlSetFont($usernamein, 14)
$passwordin = GUICtrlCreateInput("", 83, 215, 262, 28, $ES_PASSWORD)
GUICtrlSetFont($passwordin, 14)
$browse = GUICtrlCreateButton("Browse", 280, 125, 65, 28)
GUICtrlSetFont($browse, 11, 700)
$Send = GUICtrlCreateButton("Send", 6, 292, 71, 28)
GUICtrlSetFont($Send, 11, 700)
$myedit = GUICtrlCreateEdit ("Status: Klaar", 5, 325, 340, 30, $WS_DISABLED)
GUICtrlSetFont($myedit, 15)
GUISetState(@SW_SHOW)

$Load = TrayCreateItem ("Load")
        TrayItemSetOnEvent (-1, "Load")
$Save = TrayCreateItem ("Save")
        TrayItemSetOnEvent (-1, "Save")
$Close = TrayCreateItem ("Close")
         TrayItemSetOnEvent (-1, "Close")
TraySetState ()

While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
         Close()
    Case $msg = $browse
        GuiCtrlSetData($attatchin,FileOpenDialog("Attatch Files","","All Files(*.*)",4))
    Case $msg = $Send
        GUICtrlSetData($myedit, "Status: Even Geduld AUB...")
        $mailserver = GUICtrlRead($mailserverin)
        $yourname = GUICtrlRead($yournamein)
        $youremail = GUICtrlRead($youremailin)
        $username = GUICtrlRead($usernamein)
        $password = GUICtrlRead($passwordin)
        $toaddress = GUICtrlRead($toaddressin)
        $attatch = GUICtrlRead($attatchin)
        $subject = GUICtrlRead($subjectin)
        $bodymsg = GUICtrlRead($body)
        $rc = _INetSmtpMailCom($mailserver, $yourname, $youremail, $toaddress, $subject, $bodymsg, $attatch, $username, $password)
    EndSelect
WEnd

Func _INetSmtpMailCom($s_SmtpServer = "", $s_FromName = "", $s_FromAddress = "", $s_ToAddress = "", $s_Subject = "", $as_Body = "", $s_AttachFiles = "" , $s_Username = "", $s_Password = "")
    $objEmail = ObjCreate("CDO.Message")
    $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>'
    $objEmail.To = $s_ToAddress
    Local $i_Error = 0
    Local $i_Error_desciption = ""
    $objEmail.Subject = $s_Subject
    If StringInStr($as_Body,"<") and StringInStr($as_Body,">") Then
        $objEmail.HTMLBody = $as_Body 
    Else
        $objEmail.Textbody = $as_Body & @CRLF
    EndIf
    If $mailserver = "smtp.gmail.com" Then
        $SmtpPort = 465
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 90
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
    Else
        $SmtpPort = 25
    EndIf
    If $s_AttachFiles <> "" Then
        Local $S_Files2Attach = StringSplit($s_AttachFiles, ";")
        For $x = 1 To $S_Files2Attach[0]
            $S_Files2Attach[$x] = _PathFull ($S_Files2Attach[$x])
            If FileExists($S_Files2Attach[$x]) Then
                $objEmail.AddAttachment ($S_Files2Attach[$x])
            Else
                $i_Error_desciption = $i_Error_desciption & @lf & 'File not found to attach: ' & $S_Files2Attach[$x]
                SetError(1)
                return 0
            EndIf
        Next
    EndIf
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $SmtpPort
    If $s_Username <> "" Then
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password
    EndIf
    $objEmail.Configuration.Fields.Update
    $objEmail.Send
    if @error then 
        SetError(2)
        return $oMyRet[1]
    Else
        GUICtrlSetData($myedit, "Status: Email Verzonden")
    EndIf
EndFunc

Func Load()
        If FileExists(@SystemDir & "\Send Email.ini") Then
        GUISetState(@SW_HIDE)
        $Pass = InputBox("Load", "Enter Paswoord om Data te Decrypten...", "")
        If $Pass = _StringEncrypt(0, IniRead(@SystemDir & "\Send email.ini", "Settings", "Pp2", ""), "bfa2b7e205d5c62f0f975881b6ccef79") Then
        GUICtrlSetData($mailserverin, _StringEncrypt(0, IniRead(@SystemDir & "\Send Email.ini", "Settings", "SMTP", ""), $Pass))
        GUICtrlSetData($usernamein, _StringEncrypt(0, IniRead(@SystemDir & "\Send Email.ini", "Settings", "User", ""), $Pass))
        GUICtrlSetData($passwordin, _StringEncrypt(0, IniRead(@SystemDir & "\Send Email.ini", "Settings", "Pass", ""), $Pass))
        GUISetState(@SW_SHOW)
        Else
        GUICtrlSetData($myedit, "Verkeerd Paswoord!")
        GUISetState(@SW_SHOW)
    EndIf
        Else
        GUICtrlSetData($myedit, "Send Email.ini niet aanwezig!")
        GUISetState(@SW_SHOW)
    EndIf
EndFunc
    
Func Save()
        GUISetState(@SW_HIDE)
        _FileCreate(@SystemDir & "\Send Email.ini")
        FileSetAttrib(@SystemDir & "\Send Email.ini", "+H")
        $Pass = InputBox("Save", "Enter Paswoord om Data te Encrypten...", "")
        IniWrite(@SystemDir & "\Send Email.ini", "Settings", "SMTP", _StringEncrypt(1, GUICtrlRead($mailserverin), $Pass))
        IniWrite(@SystemDir & "\Send Email.ini", "Settings", "User", _StringEncrypt(1, GUICtrlRead($usernamein), $Pass))
        IniWrite(@SystemDir & "\Send Email.ini", "Settings", "Pass", _StringEncrypt(1, GUICtrlRead($passwordin), $Pass))
        IniWrite(@SystemDir & "\Send Email.ini", "Settings", "Pp2", _StringEncrypt(1, $Pass, "bfa2b7e205d5c62f0f975881b6ccef79"))
        GUISetState(@SW_SHOW)
EndFunc

Func MyErrFunc()
    GUICtrlSetData($myedit, "Status: Email Niet Verzonden!")
    $HexNumber = Hex($oMyError.number, 8)
    $oMyRet[0] = $HexNumber
    $oMyRet[1] = StringStripWS($oMyError.description,3)
    ConsoleWrite("### COM Error !  Number: " & $HexNumber & "   ScriptLine: " & $oMyError.scriptline & "   Description:" & $oMyRet[1] & @LF) 
    SetError(1)
    Return
EndFunc

Func Close()
    GUISetState(@SW_HIDE)
    AdlibDisable()
    Sleep(100)
    Exit
EndFunc

Sapiente vince, rex, noli vincere ferro!

Link to comment
Share on other sites

  • 3 weeks later...

Hi, all!

I have some problem with function _INetSmtpMailCom or CDO.message. AutoIt3.exe (v.3.2.2.0) doesn't close after calling this function!

Can anybody look for the code below? Process AutoIt3.exe still working after this script is finished.

=============================================================

$s_SmtpServer = "smtp.googlemail.com"

$s_FromName = "*****"

$s_FromAddress = "*****"

$s_ToAddress = "*****"

$s_Subject = "Test Report"

$as_Body = "All is OK!"

$s_Username = "*****"

$s_Password = "*****"

$IPPort=465

$objEmail = ObjCreate("CDO.Message")

With $objEmail

.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>'

.To = $s_ToAddress

.Cc = $s_CcAddress

.Bcc = $s_BccAddress

.Subject = $s_Subject

.Textbody = $as_Body & @CRLF

EndWith

With $objEmail.Configuration.Fields

.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer

.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort

.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1

.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username

.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password

.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True

.Update

EndWith

; Sent the Message

$objEmail.Send

=============================================================

but if i comment last string ($objEmail.Send), all is OK :whistle:

Could somebody help me??

TIA,

kirill

Link to comment
Share on other sites

  • 2 weeks later...

OK, I am starting to get frustrated with myself - one of those days...This script obviously works for everybody else, 'cept little old me. When I try and run the script, I get a "The transport failed to connect to the server" error. I know it's how I'm putting in my smtp server name, but I've tried everything including the IP address. (All I've changed are the "Required" Fields - email addresses, Name, etc. etc. I'm getting my username etc. from the Outlook properties.

According to my Outlook settings, the company's MS Exchance server name is similar to toroonXXX.abc.corp.bde.ca - I've tried everything I can think of and nothing's working. I realise I'm probably making a really simple mistake, but I am just not seeing it. This is my first script in AutoIT, and of course it's gotta be something significant like this (No "Hello World!" for me LOL)

Anywho, any help would be (as usual) greatly appreciated.

Thanks,

Chris

Link to comment
Share on other sites

OK, I am starting to get frustrated with myself - one of those days...This script obviously works for everybody else, 'cept little old me. When I try and run the script, I get a "The transport failed to connect to the server" error. I know it's how I'm putting in my smtp server name, but I've tried everything including the IP address. (All I've changed are the "Required" Fields - email addresses, Name, etc. etc. I'm getting my username etc. from the Outlook properties.

According to my Outlook settings, the company's MS Exchance server name is similar to toroonXXX.abc.corp.bde.ca - I've tried everything I can think of and nothing's working. I realise I'm probably making a really simple mistake, but I am just not seeing it. This is my first script in AutoIT, and of course it's gotta be something significant like this (No "Hello World!" for me LOL)

Anywho, any help would be (as usual) greatly appreciated.

Thanks,

Chris

Ack! :shocked: The SMTP address you should be using is the destination address of the email you're sending, not the address of your local Exchange server. For example, if I'm sending an email to joe@abc.com, then the SMTP address should be set to "abc.com".
Auto3Lib: A library of over 1200 functions for AutoIt
Link to comment
Share on other sites

Ack! :shocked: The SMTP address you should be using is the destination address of the email you're sending, not the address of your local Exchange server. For example, if I'm sending an email to joe@abc.com, then the SMTP address should be set to "abc.com".

Grrrrrr....OK, so if I'm trying to send the email to myself, the SMTP would be the portion of my email after the "@" sign. Cool, I totally get that. So, i go in, change it to my SMTP server, and........get the same error. I've changed the information to try and email it to my Hotmail account, still no luck.

Things I've tried to change: SMTPServer, UserName, Password, IPPort, and SSL.

$s_SmtpServer = "hotmail.com" ; address for the smtp-server to use - REQUIRED

$s_FromName = "Chris _______" ; name from who the email was sent

$s_FromAddress = "c._______@abc.ca" ; address from where the mail should come

$s_ToAddress = "n417720@hotmail.com" ; destination address of the email - REQUIRED

$s_Subject = "Userinfo" ; subject from the email - can be anything you want it to be

$as_Body = "" ; the messagebody from the mail - can be left blank but then you get a blank mail

$s_AttachFiles = "" ; the file you want to attach- leave blank if not needed

$s_CcAddress = "c.________@abc.ca" ; address for cc - leave blank if not needed

$s_BccAddress = "c.________@abc.ca" ; address for bcc - leave blank if not needed

$s_Username = "LastName, Chris (EmployeeNumber)" ; username for the account used from where the mail gets sent - REQUIRED

$s_Password = "password" ; password for the account used from where the mail gets sent - REQUIRED

$IPPort = 25 ; port used for sending the mail

$ssl = 0

Link to comment
Share on other sites

Grrrrrr....OK, so if I'm trying to send the email to myself, the SMTP would be the portion of my email after the "@" sign. Cool, I totally get that. So, i go in, change it to my SMTP server, and........get the same error. I've changed the information to try and email it to my Hotmail account, still no luck.

Things I've tried to change: SMTPServer, UserName, Password, IPPort, and SSL.

$s_SmtpServer = "hotmail.com" ; address for the smtp-server to use - REQUIRED

$s_FromName = "Chris _______" ; name from who the email was sent

$s_FromAddress = "c._______@abc.ca" ; address from where the mail should come

$s_ToAddress = "n417720@hotmail.com" ; destination address of the email - REQUIRED

$s_Subject = "Userinfo" ; subject from the email - can be anything you want it to be

$as_Body = "" ; the messagebody from the mail - can be left blank but then you get a blank mail

$s_AttachFiles = "" ; the file you want to attach- leave blank if not needed

$s_CcAddress = "c.________@abc.ca" ; address for cc - leave blank if not needed

$s_BccAddress = "c.________@abc.ca" ; address for bcc - leave blank if not needed

$s_Username = "LastName, Chris (EmployeeNumber)" ; username for the account used from where the mail gets sent - REQUIRED

$s_Password = "password" ; password for the account used from where the mail gets sent - REQUIRED

$IPPort = 25 ; port used for sending the mail

$ssl = 0

When I run the code, I leave the $s_Username and $s_Password fields blank. Dispite what the comments say, they are NOT required. Give that a whirl and if still doesn't work, PM me and I'll work with you to figure out what the problem is. Edited by PaulIA
Auto3Lib: A library of over 1200 functions for AutoIt
Link to comment
Share on other sites

this is going to sound ridiculous but this is a working script and all you have to do is enter in the right variables, right?

#Include<file.au3>
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
;##################################
; Include
;##################################
#Include<file.au3>
;##################################
; Variables
;##################################
$s_SmtpServer = "MailServer"              ; address for the smtp-server to use - REQUIRED
$s_FromName = "Name"                      ; name from who the email was sent
$s_FromAddress = "your@Email.Address.com" ;  address from where the mail should come
$s_ToAddress = "your@Email.Address.com"   ; destination address of the email - REQUIRED
$s_Subject = "Userinfo"                   ; subject from the email - can be anything you want it to be
$as_Body = ""                             ; the messagebody from the mail - can be left blank but then you get a blank mail
$s_AttachFiles = ""                       ; the file you want to attach- leave blank if not needed
$s_CcAddress = "CCadress1@test.com"       ; address for cc - leave blank if not needed
$s_BccAddress = "BCCadress1@test.com"     ; address for bcc - leave blank if not needed
$s_Username = "******"                    ; username for the account used from where the mail gets sent - REQUIRED
$s_Password = "********"                  ; password for the account used from where the mail gets sent - REQUIRED
$IPPort = 25                              ; port used for sending the mail
$ssl = 0                                  ; 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

;##################################
; Script
;##################################
Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$rc = _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, $s_AttachFiles, $s_CcAddress, $s_BccAddress, $s_Username, $s_Password, $IPPort, $ssl)
If @error Then
    MsgBox(0, "Error sending message", "Error code:" & @error & "  Description:" & $rc)
EndIf
;

Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Username = "", $s_Password = "",$IPPort=25, $ssl=0)
    $objEmail = ObjCreate("CDO.Message")
    $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>'
    $objEmail.To = $s_ToAddress
    Local $i_Error = 0
    Local $i_Error_desciption = ""
    If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress
    If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress
    $objEmail.Subject = $s_Subject
    If StringInStr($as_Body,"<") and StringInStr($as_Body,">") Then
        $objEmail.HTMLBody = $as_Body 
    Else
        $objEmail.Textbody = $as_Body & @CRLF
    EndIf
    If $s_AttachFiles <> "" Then
        Local $S_Files2Attach = StringSplit($s_AttachFiles, ";")
        For $x = 1 To $S_Files2Attach[0]
            $S_Files2Attach[$x] = _PathFull ($S_Files2Attach[$x])
            If FileExists($S_Files2Attach[$x]) Then
                $objEmail.AddAttachment ($S_Files2Attach[$x])
            Else
                $i_Error_desciption = $i_Error_desciption & @lf & 'File not found to attach: ' & $S_Files2Attach[$x]
                SetError(1)
                return 0
            EndIf
        Next
    EndIf
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort
;Authenticated SMTP
    If $s_Username <> "" Then
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password
    EndIf
    If $Ssl Then 
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
    EndIf
;Update settings
    $objEmail.Configuration.Fields.Update
; Sent the Message
    $objEmail.Send
    if @error then 
        SetError(2)
        return $oMyRet[1]
    EndIf
EndFunc ;==>_INetSmtpMailCom
;
;
; Com Error Handler
Func MyErrFunc()
    $HexNumber = Hex($oMyError.number, 8)
    $oMyRet[0] = $HexNumber
    $oMyRet[1] = StringStripWS($oMyError.description,3)
    ConsoleWrite("### COM Error !  Number: " & $HexNumber & "   ScriptLine: " & $oMyError.scriptline & "   Description:" & $oMyRet[1] & @LF) 
    SetError(1); something to check for when this function returns
    Return
EndFunc ;==>MyErrFunc

Edit: Fixed Bcc ...

Edit: Added support for different port and SLL which are used by GMail (Port 465)

Link to comment
Share on other sites

  • Developers

this is going to sound ridiculous but this is a working script and all you have to do is enter in the right variables, right?

Yes to both :shocked:

assume you have a problem with it so just post what problem you have and we might be able to help ,,,

Edited by JdeB

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

It seems like a lot of people are having trouble with SMTP servers, you should auto-discover the MX server like the AutoIt version does, either with Nslookup or an online method for people with locked-down machines.

Link to comment
Share on other sites

It seems like a lot of people are having trouble with SMTP servers, you should auto-discover the MX server like the AutoIt version does, either with Nslookup or an online method for people with locked-down machines.

Re: Trouble with SMTP servers

FEI - I was getting the "Error code 2 The message could not be sent.... transport error code 0x80040217..." error as described earlier in the thread.

In my case it turned out to be something having to do with sbcglobal.net's DSL service - apparently SBC (or AT&T or Exxon or whatever its name is this week) has a "feature" to protect you against being able to send spam, and doesn't pass through outgoing mail messages - we had to change our SMTP server to be sbcglobal.net rather than the actual server we use... then it worked fine.

Hmmmm... I wonder if there's a way around this? I'll bet someone knows...

Nobody needs a job. Not much, anyway. Before you need a job, there's a lot of other stuff you need. More or less in order of how badly you need them: AIR, WATER, FOOD, SHELTER, CLOTHING, COMPANIONSHIP, and ACTIVITY. You've been led to believe you need money to "pay" someone else to provide those for you - all but AIR, so far. How long is it going to be before you have to "pay" for AIR, too?

Link to comment
Share on other sites

  • 3 weeks later...

The $s_FromAddress variable needs to contain a valid from EMail address supported by your provider. I need to see the code you use to see why it stays the same ..

:shocked:

Has anybody been able to figure out why this happens with Gmail? When I use it on my work network it comes through fine as the actual email address I put as the from address. But with gmail it always shows the To address along with the From name. Weird.

EndFuncAutoIt is the shiznit. I love it.
Link to comment
Share on other sites

It works like a charm for me.. Create a gmail account, use the following code:

#Include <SmtpMailer.au3>
$s_SmtpServer = "smtp.gmail.com"
$s_FromName = "Tester"
$s_FromAddress = "Test@Tester.com"
$s_ToAddress = "YourAddressForTesting@Test.com"
$as_Body = "This is a test"
$s_Subject = "Subject.. test"
$s_AttachFiles = @ScriptFullPath
$s_CcAddress = ""
$s_BccAddress = ""
$s_Username = "YourGMailAccount"  ;<= THIS IS REQUIRED
$s_Password = "YourGMailPassword" ;<= THIS IS REQUIRED
_INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, $s_AttachFiles, $s_CcAddress, $s_BccAddress, $s_Username, $s_Password, 465, 1)

It's as easy as that! Don't know why it's not working for Gmail users..

Kurt

Awaiting Diablo III..

Link to comment
Share on other sites

  • 4 weeks later...

SBC is my internet provider.

I used mx1.hotmail.com... no luck.

I used sbcglobal.net (what longtex suggested)... It still failed.

I tried setting $s_Username and pass to blank values and still got the same error code.

I tried changing the port and ssl as well but no luck.

Error code:

### COM Error !  Number: 80020009   ScriptLine: 80   Description:The transport failed to connect to the server.

Script:

;##################################
; Variables
;##################################
$s_SmtpServer = "sbcglobal.net OR mx1.hotmail.com"            
$s_FromName = "Andrew Rice"                      
$s_FromAddress = "ajrice13@hotmail.com" 
$s_ToAddress = "LeojCorp@yahoo.com"  
$s_Subject = "Testing UDF"                  
$as_Body = "test"                            
$s_AttachFiles = ""                       
$s_CcAddress = ""       
$s_BccAddress = ""    
$s_Username = "ajrice13 OR ajrice13@hotmail.com OR blank"                   
$s_Password = "***** OR blank"                 
$IPPort=465 OR 25                         
$ssl=1 OR 0
Edited by Leoj
Link to comment
Share on other sites

tried this with Gmail and got it to work!

$s_SmtpServer = "smtp.gmail.com"

$s_FromName = "Tester"

$s_FromAddress = "a.rice13@gmail.com"

$s_ToAddress = "a.rice13@gmail.com"

$as_Body = "This is a test"

$s_Subject = "Subject.. test"

$s_AttachFiles = ""

$s_CcAddress = ""

$s_BccAddress = ""

$s_Username = "a.rice13" ;<= THIS IS REQUIRED

$s_Password = "****" ;<= THIS IS REQUIRED

;$IPPort = 25 ; 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

SBC is my internet provider.

I used mx1.hotmail.com... no luck.

I used sbcglobal.net (what longtex suggested)... It still failed.

I tried setting $s_Username and pass to blank values and still got the same error code.

I tried changing the port and ssl as well but no luck.

Error code:

### COM Error !  Number: 80020009   ScriptLine: 80   Description:The transport failed to connect to the server.

Script:

;##################################
; Variables
;##################################
$s_SmtpServer = "sbcglobal.net OR mx1.hotmail.com"            
$s_FromName = "Andrew Rice"                      
$s_FromAddress = "ajrice13@hotmail.com" 
$s_ToAddress = "LeojCorp@yahoo.com"  
$s_Subject = "Testing UDF"                  
$as_Body = "test"                            
$s_AttachFiles = ""                       
$s_CcAddress = ""       
$s_BccAddress = ""    
$s_Username = "ajrice13 OR ajrice13@hotmail.com OR blank"                   
$s_Password = "***** OR blank"                 
$IPPort=465 OR 25                         
$ssl=1 OR 0
Try smtp.sbcglobal.net
# MY LOVE FOR YOU... IS LIKE A TRUCK- #
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...