PureSMTP library : mail & attachments (AUTH supported)

All PureFORM, JaPBe, Libs and useful code maintained by gnozal

Moderator: gnozal

maw

Post by maw »

Probably because you have a corporate firewall blocking external SMPT-access at work.
User avatar
doctorized
Addict
Addict
Posts: 882
Joined: Fri Mar 27, 2009 9:41 am
Location: Athens, Greece

Post by doctorized »

I have AVG 8.5 Internet security installed and when it asks if I want to let the program connect I say yes but the connection fails. I have the same program instaleed at home and there is no problem.
(Both computers connect directly to the web.)
User avatar
doctorized
Addict
Addict
Posts: 882
Joined: Fri Mar 27, 2009 9:41 am
Location: Athens, Greece

Post by doctorized »

maw wrote:Probably because you have a corporate firewall blocking external SMPT-access at work.
Even if I shut the firewall down the problem still exists.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Post the code you're using (and remove the login/password first).
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
doctorized
Addict
Addict
Posts: 882
Joined: Fri Mar 27, 2009 9:41 am
Location: Athens, Greece

Post by doctorized »

PB wrote:Post the code you're using (and remove the login/password first).

Code: Select all

If OpenWindow(0, 300, 300, 260, 210,"Email Window", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)

If CreateGadgetList(WindowID(0))
StringGadget(0,50,10,200,20,"");server
StringGadget(1,50,32,200,20,"");sender
StringGadget(2,50,54,200,20,"");taker
StringGadget(3,50,76,200,20,"");login name
StringGadget(4,50,98,200,20,"");login password
StringGadget(5,50,120,200,20,"");mail body
TextGadget(6,10,12,40,20,"smtp :")
TextGadget(7,10,34,40,20,"sender :")
TextGadget(8,10,56,40,20,"taker :")
TextGadget(9,10,78,40,20,"ID :")
TextGadget(10,10,100,40,20,"pass :")
TextGadget(11,10,122,40,20,"body :")
TextGadget(12,10,144,40,20,"interval :")
StringGadget(13,50,142,40,20,"30")
ButtonGadget(14,90,170,80,30,"OK with pass")
EndIf

Repeat
EventID = WaitWindowEvent()
If EventID = #PB_Event_CloseWindow  
Quit = 1
ElseIf EventID = #PB_Event_Gadget
Select EventGadget()
Case 14
MySMTPServer.s = GetGadgetText(0)
MySMTPPort.l = 25 
TimeOut.l = Val(GetGadgetText(13))
PureSMTP_SetTimeOut(TimeOut)
If PureSMTP_OpenSMTPConnection(MySMTPServer, MySMTPPort) = #PureSMTP_Ok 
MailTo.s = GetGadgetText(2)
MailFrom.s = GetGadgetText(1) 
Subject.s ="Hi!"
MsgBody.s = GetGadgetText(5) 
Attachments.s
UserName.s = GetGadgetText(3)
Password.s = GetGadgetText(4)
Status.l = PureSMTP_SendMail(MailTo, MailFrom, Subject, MsgBody, Attachments, UserName, Password) 
If Status = #PureSMTP_Ok
MessageRequester("sent:" + Str(Status),PureSMTP_GetLastServerMessage())
Else 
MessageRequester("failed:" + Str(Status),PureSMTP_GetLastServerMessage())
EndIf 
PureSMTP_CloseSMTPConnection() 
Else 
MessageRequester("OpenSMTPConnection failed",PureSMTP_GetLastServerMessage())
EndIf
EndSelect
EndIf

Until Quit = 1

EndIf

End
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: Spam mail

Post by gnozal »

doctorized wrote:I use the example code included in the zip file of PureSMTP lib and all the massages sent goes to the spam folder and not the inbox. Why?
Maybe you could change the X-mailer ?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

The error code returned by PureSMTP_SendMail() as well as the PureSMTP_GetLastServerMessage() could help.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
doctorized
Addict
Addict
Posts: 882
Joined: Fri Mar 27, 2009 9:41 am
Location: Athens, Greece

Re: Spam mail

Post by doctorized »

gnozal wrote:
doctorized wrote:I use the example code included in the zip file of PureSMTP lib and all the massages sent goes to the spam folder and not the inbox. Why?
Maybe you could change the X-mailer ?

Change it to what? I do not know what to give.
User avatar
doctorized
Addict
Addict
Posts: 882
Joined: Fri Mar 27, 2009 9:41 am
Location: Athens, Greece

Post by doctorized »

gnozal wrote:The error code returned by PureSMTP_SendMail() as well as the PureSMTP_GetLastServerMessage() could help.

PureSMTP_GetLastServerMessage() returns nothing.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: Spam mail

Post by gnozal »

doctorized wrote:
gnozal wrote:
doctorized wrote:I use the example code included in the zip file of PureSMTP lib and all the massages sent goes to the spam folder and not the inbox. Why?
Maybe you could change the X-mailer ?
Change it to what? I do not know what to give.
To 'Lotus Notes Release 6.5.5 November 30, 2005' or 'Microsoft Office Outlook, Build 11.0.5510' for example, any well known mail client.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

doctorized wrote:
gnozal wrote:The error code returned by PureSMTP_SendMail() as well as the PureSMTP_GetLastServerMessage() could help.
PureSMTP_GetLastServerMessage() returns nothing.
And PureSMTP_SendMail() ?
PureSMTP.chm wrote:Error codes :
#PureSMTP_FileError = -1
#PureSMTP_NoConnection = -2
#PureSMTP_BadResponse = - 3
#PureSMTP_MemoryAllocationProblem = -4
#PureSMTP_AuthentificationFailed = -5
#PureSMTP_ServerTimeOut = -6
#PureSMTP_Abort = -7
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
doctorized
Addict
Addict
Posts: 882
Joined: Fri Mar 27, 2009 9:41 am
Location: Athens, Greece

Post by doctorized »

gnozal wrote:
doctorized wrote:
gnozal wrote:The error code returned by PureSMTP_SendMail() as well as the PureSMTP_GetLastServerMessage() could help.
PureSMTP_GetLastServerMessage() returns nothing.
And PureSMTP_SendMail() ?
PureSMTP.chm wrote:Error codes :
#PureSMTP_FileError = -1
#PureSMTP_NoConnection = -2
#PureSMTP_BadResponse = - 3
#PureSMTP_MemoryAllocationProblem = -4
#PureSMTP_AuthentificationFailed = -5
#PureSMTP_ServerTimeOut = -6
#PureSMTP_Abort = -7
PureSMTP_SendMail() returns -2.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

doctorized wrote:PureSMTP_SendMail() returns -2.
That means there is no current connection, i.e. PureSMTP_OpenSMTPConnection() failed or you called PureSMTP_CloseSMTPConnection(). This is strange, because in the code you posted, PureSMTP_SendMail() isn't called if PureSMTP_OpenSMTPConnection() failed.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
doctorized
Addict
Addict
Posts: 882
Joined: Fri Mar 27, 2009 9:41 am
Location: Athens, Greece

Post by doctorized »

gnozal wrote:That means there is no current connection, i.e. PureSMTP_OpenSMTPConnection() failed or you called PureSMTP_CloseSMTPConnection(). This is strange, because in the code you posted, PureSMTP_SendMail() isn't called if PureSMTP_OpenSMTPConnection() failed.
PureSMTP_SendMail() returns -2 if I cut the "If" from the PureSMTP_OpenSMTPConnection() so PureSMTP_SendMail() is called.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

I guess PureSMTP_OpenSMTPConnection() fails because you have a corporate firewall / proxy at work, and unfortunately Purebasic network functions don't support proxies.
I have the same issue at work.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Post Reply