25-11-2014, 05:42 AM
اضف ssleay32.dll و libeay32.dll الى مشروعك
واذا كنت تستخدم الجمايل انتقل الى هذا الرابط
https://www.google.com/settings/security/lesssecureapps
لتفعيل الوصول الى حسابك
بالتوفيق
واذا كنت تستخدم الجمايل انتقل الى هذا الرابط
https://www.google.com/settings/security/lesssecureapps
لتفعيل الوصول الى حسابك
بالتوفيق
PHP كود :
uses
idsmtp,idmessage,IdTCPConnection, IdTCPClient, IdExplicitTLSClientServerBase,
IdMessageClient, IdSMTPBase,IdBaseComponent, IdComponent, IdIOHandler,
IdIOHandlerSocket, IdIOHandlerStack, IdSSL, IdSSLOpenSSL;
function SendEmail(sTo, sSubject, sText,sUserName,sPassWord: string):string;
const
_HOST = 'smtp . live . com';
_PORT = 587;
var
crPrevious : TCursor;
idSSL : TIdSSLIOHandlerSocketOpenSSL;
idSMTP: TIdSMTP;
email : TIdMessage;
begin
crPrevious := Screen.Cursor;
Screen.Cursor := crHourGlass;
idSSL := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
idSSL.SSLOptions.Method := sslvTLSv1;
idSSL.SSLOptions.Mode := sslmUnassigned;
idSMTP := TIdSMTP.Create(nil);
idSMTP.IOHandler := idSSL;
idSMTP.UseTLS := utUseExplicitTLS;
idSMTP.Host := _HOST;
idSMTP.Port := _PORT;
idSMTP.UserName := sUserName; // Votre compte
idSMTP.Password := sPassWord; // Votre mot de passe
email := TIdMessage.Create(nil);
email.From.Address := sUserName;
email.Recipients.EMailAddresses := sTo;
email.Subject := sSubject;
email.Body.Text := sText;
idSMTP.Connect;
try
try
idSMTP.Send(email);
Result :='succès'
except on g:Exception do
Result := g.Message
end;
finally
idSMTP.Disconnect;
idSSL.Free;
idSMTP.Free;
email.Free;
Screen.Cursor := crPrevious;
end;
end;

