[Gambas-user] About SMTP component

Willy Raets willy at ...2734...
Wed Oct 22 16:29:25 CEST 2014


On wo, 2014-10-22 at 12:49 +0200, Jorge Carrión wrote:
> I've a problem with gambas 3.6 Smtpclient (with previous versions too).
> perhaps I don't understand very well the SMTP protocol or I don't undestand
> what some propertis of SmtpClient are, but If someone can help me I'll
> appreciate it very much:

I have added a source archive with application MailTester

1. It allows you to test mail with the settings entered in the form
fields. Note that these are saved as setings (using gb.settings) and the
password is stored in keyring (using gb.desktop) except for attachment
path.

2. It also allows you to browse for an attachment and add it to the test
mail.

3. It sends the mail to your from mail address and adds some body
content to let you know it worked.

4. If using authentication it needs Gambas 3.6 at least (as
authentication was still buggy pre 3.6)


> 
> I use this function to send eMails:
> 
> Public Sub enviarmail(aTo As String[], cSubject As String, cTexto As
> String, cFrom As String, Optional aAttacheds As String[], Optional bcc As
> String[])
> 
>     Dim SmtpC As New SmtpClient
>     Dim s, fich, mime, fname As String
> 
>     SmtpC.debug = True
>     SmtpC.host = mcomun.mailserver["host"]
>     SmtpC.user = mcomun.mailserver["user"]
>     SmtpC.password = mcomun.mailserver["password"]
>     SmtpC.From = cFrom
>     For Each s In aTo
>         SmtpC.To.Add(s)
>     Next
>     SmtpC.Subject = cSubject
>     SmtpC.Body = cTexto
>     SmtpC.Alternative = False    ''Not sure about this is for
>     If Not IsNull(aAttacheds) Then
>         For Each fich In aAttacheds
>             Exec ["file", "-bi", fich] To mime
>             mime = Left(mime, InStr(mime, ";") - 1)
>             fname = Right(fich, - RInStr(fich, "/"))
>             SmtpC.Add(File.Load(fich), mime, fname)
>         Next
>     Endif
>     If Not IsNull(bcc) Then
>         For Each s In bcc
>             SmtpC.bcc.Add(s)
>         Next
>     Endif
>     SmtpC.Encrypt = Net.SSL
>     SmtpC.send
> 
> End

You can test MailTester and if it works for you compare the code to
yours.

I have tested this with .png, .tar, .txt and .deb attachments and they
are all nicely added.

I also attached a screenshot of one of the test mails received.


Hope this will help.

-- 
Kind regards,

Willy (aka gbWilly)

http://gambasshowcase.org/
http://howtogambas.org
http://gambos.org



-------------- next part --------------
A non-text attachment was scrubbed...
Name: MailRecieved.png
Type: image/png
Size: 21316 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20141022/11c60c17/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MailTester-0.0.2.tar.gz
Type: application/x-compressed-tar
Size: 6923 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20141022/11c60c17/attachment.bin>


More information about the User mailing list