Sending Mail

Just starting out? Need help? Post your questions and find answers here.
jimcorr
New User
New User
Posts: 7
Joined: Sun Dec 14, 2014 11:38 pm

Sending Mail

Post 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.
User avatar
RichAlgeni
Addict
Addict
Posts: 935
Joined: Wed Sep 22, 2010 1:50 am
Location: Bradenton, FL

Re: Sending Mail

Post 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?
jimcorr
New User
New User
Posts: 7
Joined: Sun Dec 14, 2014 11:38 pm

Re: Sending Mail

Post 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,
User avatar
RichAlgeni
Addict
Addict
Posts: 935
Joined: Wed Sep 22, 2010 1:50 am
Location: Bradenton, FL

Re: Sending Mail

Post by RichAlgeni »

If they only allow SSL, you will need need a different approach, see this link:

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