smtp的问题NMSMTP1->SendMail();报错了(503 error:need EHLO and AUTH first)
#include <vcl.h>
#include "main.h"
#include "email.h"
#pragma hdrstop
//---------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
Tf_email *f_email;
//---------------------------------------
__fastcall Tf_email::Tf_email(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------
void __fastcall Tf_email::FormShow(TObject *Sender)
{
main1->Hide();
}
//---------------------------------------
void __fastcall Tf_email::FormClose(TObject *Sender, TCloseAction &Action)
{
main1->Show();
}
//---------------------------------------
void __fastcall Tf_email::SpeedButton1Click(TObject *Sender)
{
NMSMTP1->host="smtp.qq.com";
NMSMTP1->port=25
NMSMTP1->UserID = Edit3->Text; //填入User Name
NMSMTP1->Connect();
ShowMessage("连上了服务器");
}
//---------------------------------------
void __fastcall Tf_email::SpeedButton2Click(TObject *Sender)
{
NMSMTP1->PostMessage->FromAddress = "544321783@qq.com"; //填入寄信者的e-mail address
NMSMTP1->PostMessage->FromName = "544321783"; //填入寄件者的姓名
NMSMTP1->PostMessage->Subject = "sfdgfdsg"; //填入信件標題
NMSMTP1->PostMessage->ToAddress->Add("403374558"); //填入收信人的E-mail Address
NMSMTP1->PostMessage->Body->Assign("hahah"); //填入信件內容
ShowMessage("oh my 嘎!!come on!!!") ;
NMSMTP1->SendMail();
}
//---------------------------------------
[解决办法]
503 error是服务器给你的错误信息,看是不是少了什么操作
[解决办法]
TNMSMTP 不提供密码验证功能,建议你改用indy组件