This function sends an email using SMTP protocol.
Syntax
function ibec_smtp_SendMail(SMTPHost : string; SMTPPort : string; UserName : string; Password : string; From : string; To : string; CC : string; BCC : string; Subject : string; Message : string; AttachedFiles : string; AdditionalHeaders : string; Options : string; CallbackBlock : string) : variant;
Features:
Options (still in work):
AuthType | E.g. AuthType=NONE |
Priority | Highest/High/Normal/Low/Lowest |
… |
ibec_smtp_SendMail(..., 'Encoding=windows-1251; Confirm; Priority=Highest; AuthType=NONE', cbb);
See also the examples below.
execute ibeblock as begin CRLF = ibec_CRLF(); cbb = 'execute ibeblock (Vals variant) as begin sPref = ''''; sEvent = Vals[''EVENT'']; if ((sEvent = ''COMMAND'') or (sEvent = ''HEADER'')) then sPref = ''==> ''; else if (sEvent = ''RESPONSE'') then sPref = ''<== ''; sMes = sPref + Vals[''TEXT'']; ibec_Progress(sMes); LogFile = ibec_GetGlobalVar(''LogFileH'', null); if (LogFile is not NULL) then ibec_fs_Writeln(LogFile, sMes); end'; sMessage = 'Just a test' + CRLF + 'This message was sent by ibec_smtp_SendMail function'; sAttachments = 'D:\smtpsendmail.ibeblock' + CRLF + 'D:\script.sql'; sAddHeaders = 'IBE-Type: IBEBlock' + CRLF + 'IBE-Comment: Just a comment'; LogFile = ibec_fs_OpenFile('D:\smtp.log', __fmCreate); try if (LogFile is not null) then ibec_SetGlobalVar('LogFileH', LogFile); ibec_smtp_SendMail('mail.myserver.com', 'smtp', 'Bill', 'windows_must_die!', '"Bill Gates" <Bill@microsoft.com>', 'all@world.com', '', '', 'Test message from IBEBlock ibec_smtp_SendMail function', :sMessage, :sAttachments, :sAddHeaders, 'Encoding=windows-1251; Confirm; Priority=Highest', cbb); finally ibec_fs_CloseFile(LogFile); end; end
Res = IBEC_SMTP_SENDMAIL('smtp.gmail.com', '465', -- GMAIL requires SSL connection on this port 'some.user@gmail.com', 'masterkey', 'some.user@gmail.com', 'another.user@gmail.com', '', '', 'Subject of message', 'Text of message', '', '', 'encoding="UTF-8"; ContentType=plain; Priority=High; UseSSL', null);
Res = IBEC_SMTP_SENDMAIL('smtp.gmail.com', '25', -- GMAIL allows TLS on this port; it will be used automatically 'some.user@gmail.com', 'masterkey', 'some.user@gmail.com', 'another.user@gmail.com', '', '', 'Subject of message', 'Text of message', '', '', 'encoding="UTF-8"; ContentType=plain; Priority=High; AuthType=LOGIN', null);