Sign in to follow this  
Followers 0
Andreik

Send Mail via Telnet

3 posts in this topic

I noticed that are many people using yahoo and have problems in sending mail with _InetSmtpMail() function. Those who have problems with _InetSmtpMail () can try this function probably with more success.

I write 3 examples (all tested), just replace From and To addresses:

#include <Mail.au3>
$NAME = "Andreik"
$FROM = "user@yahoo.com"
$TO = "username@yahoo.com"
$SUBJECT = "This is a test"
$BODY = "This is only a test"
$MAIL = Mail($NAME,$FROM,$TO,$SUBJECT,$BODY)
If $MAIL Then
    MsgBox(0,"","Your message was sent")
Else
    MsgBox(0,"","An error occurred sending mail.")
EndIf

#include <Mail.au3>
$NAME = "Andreik"
$FROM = "user@yahoo.com"
$TO = "username@yahoo.com"
$SUBJECT = "This is a test (HTML)"
$BODY = "<html><body><b><u>This should be bold and underline</u></b></body></html>"
$CONTENT_TYPE = "text/html"
$MAIL = Mail($NAME,$FROM,$TO,$SUBJECT,$BODY,$CONTENT_TYPE)
If $MAIL Then
    MsgBox(0,"","Your message was sent")
Else
    MsgBox(0,"","An error occurred sending mail.")
EndIf

#include <Mail.au3>
$NAME = "Andreik"
$FROM = "user@yahoo.com"
$TO = "username@yahoo.com"
$SUBJECT = "Mail with attach file"
$BODY = "RnVuYyBNYWlsKCROQU1FLCRGUk9NLCRUTywkU1VCSkVDVCwkQk9EWT0iIiwkQ09OVEVOVF9UWVBFPSJ0ZXh0L3BsYWluIiwk

RklMRV9OQU1FPSIiLCRERVNDUklQVElPTj0iIiwkQ09OVEVOVF9FTkNPREU9IiIsJENPTlRFTlRfSUQ9IjxtYWlsX3Rlc3RAeWFo

b28uY29tPiIsJFNNVFA9ImEubXgubWFpbC55YWhvby5jb20iKQ0KTG9jYWwgJE9VVCA9IFRydWUNClRDUFN0YXJ0dXAoKQ0KJFNF

UlZFUiA9IFRDUENvbm5lY3QoVENQTmFtZVRvSVAoJFNNVFApLDI1KQ0KSWYgJFNFUlZFUiA8PiAtMSBUaGVuDQpUQ1BTZW5kKCRT

RVJWRVIsJ0hFTE8gJy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gVGhlbg0KVENQU2Vu

ZCgkU0VSVkVSLCRCT0RZICYgQENSTEYpDQpJZiBAZXJyb3IgVGhlbiAkT1VUID0gRmFsc2UNClNsZWVwKDEwMCkNCkVuZElmDQpU

Q1BTZW5kKCRTRVJWRVIsQENSTEYpDQpJZiBAZXJyb3IgVGhlbiAkT1VUID0gRmFsc2UNClNsZWVwKDEwMCkNClRDUFNlbmQoJFNF

UlZFUiwiLiIgJiBAQ1JMRikNCklmIEBlcnJvciBUaGVuICRPVVQgPSBGYWxzZQ0KU2xlZXAoMzAwKQ0KRWxzZQ0KJE9VVCA9IEZh

bHNlDQpTZXRFcnJvcihGYWxzZSwtMSwtMSkNCkVuZElmDQpUQ1BTaHV0ZG93bigpDQpSZXR1cm4gJE9VVA0KRW5kRnVuYw=="
$CONTENT_TYPE = "application/au3"
$FILE = "Mail.au3"
$DESCRIPTION = "This is an UDF"
$ENCODE = "base64"
$MAIL = Mail($NAME,$FROM,$TO,$SUBJECT,$BODY,$CONTENT_TYPE,$FILE,$DESCRIPTION,$ENCODE)
If $MAIL Then
    MsgBox(0,"","Your message was sent")
Else
    MsgBox(0,"","An error occurred sending mail.")
EndIf

Please post if something is wrong or not working.

Mail.au3


When the words fail... music speaks

Share this post


Link to post
Share on other sites



You could have used the code for _InetSmtpMail() and see how it could be fixed as it more or less does exactly what you are doing.

Anyways, I always use _InetSmtpMailCom() ... maybe I should put that in the standard UDF library. :P


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

You could have used the code for _InetSmtpMail() and see how it could be fixed as it more or less does exactly what you are doing.

Anyways, I always use _InetSmtpMailCom() ... maybe I should put that in the standard UDF library. :P

I just looked in the Inet.au3. You're right, looks very much like what I did. However it is necessary to be able to send mails with attached files. I will try to follow steps from _InetSmtpMail to make this function better where is possible.

When the words fail... music speaks

Share this post


Link to post
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
Sign in to follow this  
Followers 0