Magic User Group

Magic Wiki-Wakka : SendEmail

HomePage :: CATEGORIES | Index :: Changes :: Comments :: Search :: Login/Register

How to Send an Email:


The following will step you through writing and trying your first Magic email sending test program. It also provides insight as to some of the most common reasons why such program may not work in your context and how these could be resolved.

1) Create New program:

Properties:
General:
Name: Send Email
Task Type: Batch
Initial mode: Query
End Task Condition: Yes, After

Data:
Transaction mode: Physical
Transaction begin: None

2) Create 3 numerical Virtuals in this program task Data View:
ErroronConnect, Numeric, N5
ErroronSend, Numeric, N5
ErroronDisconnect, Numeric, N5

3) In Record Suffix Handler add the following operation:

Update ErroronConnect,
 Exp=MailConnect(1,'<SmtpServiceName>','<UserId>','<Password>')

The SmtpServiceName, UserId and Password have to be provided by your email service provider or administrator. It is advisable to test these from the machine that will run this program through a regular email client before. If you can not use these from a regular email client module on this machine, the above MailConnect() function is very likely to fail and so will be the following MailSend() function.

Note: It is not rare that the UserId and Password can be left as blank (' '). Many ISP smtp services do allow non authenticated access to their service on the basis that you are accessing them within their service network.

4) Still in Record Suffix, after above Connect operation, add:

Bloc If ErroronConnect=0
Update ErroronSend, 
 Exp= MailSend('<FromEmail>','<ToEmail>','','','Test Email','Hello Email',")
Update ErroronDisconnect,
 Exp= MailDisconnect(1,'FALSE'LOG)
End Bloc

<FromEmail> and <ToEmail> should be valid email addresses in the context of this smtp email service.
The cc, bcc and attachment have been left blank for the purpose of this simple example.

5) Still in the Record Suffix, after above Sending bloc, add:

Bloc if ErroronConnect=0 and ErroronSend=0 and ErroronDisconnect=0
 Verify Sending Test SUCCESSFUL!, Mode=Warning, Display=Box
Bloc Else
 Verify Sending Test FAILED!, Mode=Warning, Display=Box
End Bloc

6) Verify the Syntax of this program (<F8>).

7) Run the program (<F7>):

If you get a pop up message stating:Sending Test SUCCESSFUL!
It is very likely that the test email was sent to the <ToEmail> address specified in the mailSend() function above and you are done with your first Magic Email.
Bravo!

If you get a pop up message stating: Sending Test FAILED!
That is because one (or many) of the error virtuals do not return zero. Refer to the documentation about these errors and to the following notes to try to resolve the issue in your specific environment.

Possible reasons for the above test to fail:

There are many possible reasons why the above test may fail. It is not possible to list all possible causes. However, the following enumerates some of the most common reasons why it could be so. Keep in mind that sending and receiving emails is also a matter of the smtp (or IMAP or POP3 for reception) service configuration. You should seek working with the email service provider or administrator in case of any problems.

a) First thing to check is if you specified the right parameters. Check that a regular email client on the same machine can send emails while using those same parameters.

b) The '<FromEmail>' email Address is partially validated in the process. It is our experience that 'ABC' may not report errors however the email may not be actually sent as a net result.

c) We suggest you test sending with an unauthenticated (no user, no password) session and a local recipient. External recipients typically require the SMTP service to relay that in turn requires an authenticated (user, password) session.

d) By default the Magic mail functions uses port 25. This may be overwritten when specifying the service as: '<SmtpServiceName>:<PortNumber>' if a different port is to be used in your environment.

e) Magic mail functions support basic authentication. However, they do not support Transport Layer Security (TLS) authentication. This is a major cause for not being able to use Magic functions with TLS enabled email services (such as Gmail).
One option then is to look at a utility called Stunnel. This utility can add the SSL security level information required by TLS/SSL services. However, learning about how to use such utility can be a multi-days task in itself. Here are links to investigate further in such case:
http://tech.groups.yahoo.com/group/blat/
http://stunnel.mirt.net/
http://www.stunnel.org/

f) Further debugging can be achieved using some network tracing utility such as:
Etheral, available at: http://www.etheral.com

Conclusion:

The Magic mail functions are very RAD and reliable in a context for which they are meant to work within. However, there are instances where not being able to configure the email service in a manner that is compatible to what Magic's email functions can support may force you to look at other avenues than the magic mail related functions. These include a product called Blat (just Google) or specific ActiveX objects available for specific services such as Microsoft Outlook.

The original version of this page was provided by: InformaPlus

There are no comments on this page. [Add comment]

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by Wikka Wakka Wiki trunk
Page was generated in 0.1237 seconds