Page 1 of 1

Sending Mail

Posted: Sun Dec 14, 2014 11:47 pm
by jimcorr
I've seen a lot of old topics about this, but since the documentation shows the methods for sending e-mail, i'm confused. Does PureBasic sends e-mail or not? Or depends on what?

I'm trying this code, changing the mail informations, and it stays in loop forever.

Code: Select all

If InitNetwork()

If CreateMail(0, "xxxx@xxxx.com.br", "Subject test")

  SetMailBody(0, "This is the body...")
  
  AddMailRecipient(0, "xxxxxxxx@gmail.com", #PB_Mail_To)
  Debug IsMail(0)
  Debug "started...."
  Result = SendMail(0, "xxxx.xxxx.com.br", 25 , 1, "xxx@xxxxx.com.br", "xxxxxx")

  Repeat
    Progress = MailProgress(0)
    Delay(300)
    Debug Progress
    
  Until Progress = #PB_Mail_Finished Or Progress = #PB_Mail_Error
  
  If Progress = #PB_Mail_Finished
    MessageRequester("Information", "Mail correctly sent !")
  Else
    MessageRequester("Error", "Can't sent the mail !")
  EndIf
  FreeMail(0)
EndIf

Else
  Debug "Didnt work...."
EndIf
I'm totally new in PB, dont know where to start.

Re: Sending Mail

Posted: Mon Dec 15, 2014 2:51 am
by RichAlgeni
It could be any number of things. I assume your use of 'xxxxx' is to hide confidential data, but are you sure you have the email domain correct in the SendMail function? Can you open a command window and try 'telnet xxxx.xxxx.com.br 25<enter>'? Does it connect? Or do you get an error?

Re: Sending Mail

Posted: Tue Dec 16, 2014 1:16 am
by jimcorr
Hi Rich, thanks for your quick answer!

You were right, the door wasn't correct, they deactivated port 25 and now only permit connections through smtp with ssl/tls on a different port.

I changed it and now telnet and the program answers (not in loop anymore).

But i get a -2 on "progress" variable, and it doesn't send the email.

Any thoughts?

Thanks again,

Re: Sending Mail

Posted: Tue Dec 16, 2014 1:55 am
by RichAlgeni
If they only allow SSL, you will need need a different approach, see this link:

http://forums.purebasic.com/english/vie ... 4a3a617ce7