در [برای مشاهده لینک ها شما باید عضو سایت باشید برای عضویت در سایت بر روی اینجا کلیک بکنید] این قطعه کد ها رو داده ، تست کنید و نتیجه رو همینجا اعلام کنید...
[Delphi - Send email using Gmail account over implicit SSL on 465 port - Example ]
کد:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, EASendMailObjLib_TLB; // add EASendMail unit
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
oSmtp : TMail;
begin
oSmtp := TMail.Create(Application);
oSmtp.LicenseCode := 'TryIt';
// Your Gmail email address
oSmtp.FromAddr := 'gmailid@gmail.com';
// Add recipient email address
oSmtp.AddRecipientEx( 'support@emailarchitect.net', 0);
// Set email subject
oSmtp.Subject := 'simple email from gmail account';
// Set email body
oSmtp.BodyText := 'this is a test email sent from Delphi using Gmail';
// Gmail SMTP server address
oSmtp.ServerAddr := 'smtp.gmail.com';
// set direct SSL 465 port,
oSmtp.ServerPort := 465;
// detect SSL/TLS automatically
oSmtp.SSL_init();
// Gmail user authentication should use your
// Gmail email address as the user name.
// For example: your email is "gmailid@gmail.com", then the user should be "gmailid@gmail.com"
oSmtp.UserName := 'gmailid@gmail.com';
oSmtp.Password := 'yourpassword';
ShowMessage( 'start to send email ...' );
if oSmtp.SendMail() = 0 then
ShowMessage( 'email was sent successfully!' )
else
ShowMessage( 'failed to send email with the following error: '
+ oSmtp.GetLastErrDescription());
end;
end.
[Delphi - Send email using Gmail account over explicit SSL (TLS) on 25 or 587 port]
کد:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, EASendMailObjLib_TLB; // add EASendMail unit
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
oSmtp : TMail;
begin
oSmtp := TMail.Create(Application);
oSmtp.LicenseCode := 'TryIt';
// Your Gmail email address
oSmtp.FromAddr := 'gmailid@gmail.com';
// Add recipient email address
oSmtp.AddRecipientEx( 'support@emailarchitect.net', 0);
// Set email subject
oSmtp.Subject := 'simple email from gmail account';
// Set email body
oSmtp.BodyText := 'this is a test email sent from Delphi using Gmail';
// Gmail SMTP server address
oSmtp.ServerAddr := 'smtp.gmail.com';
// set 25 port, if you want to use 587 port, please change 25 to 587
oSmtp.ServerPort := 25;
// detect SSL/TLS automatically
oSmtp.SSL_init();
// Gmail user authentication should use your
// Gmail email address as the user name.
// For example: your email is "gmailid@gmail.com", then the user should be "gmailid@gmail.com"
oSmtp.UserName := 'gmailid@gmail.com';
oSmtp.Password := 'yourpassword';
ShowMessage( 'start to send email ...' );
if oSmtp.SendMail() = 0 then
ShowMessage( 'email was sent successfully!' )
else
ShowMessage( 'failed to send email with the following error: '
+ oSmtp.GetLastErrDescription());
end;
end.
توضیحات انگلیسی اش هم تقریبا واضحه ...
علاقه مندي ها (Bookmarks)