Hello I'm trying to send a message from delphi (indy) to a gmail address. When I go to Gmail I found my message in spam folder. If I try to send the same message with PHPMailer from web it works correctly. This is the code.
Thanks
//setup SMTP
SMTP.Port := 25;
SMTP.ConnectTimeout := 1000;
SMTP.Host := 'smtp.xxxxxx.it';
SMTP.Username := 'info@xxxxxx.it';
SMTP.Password := 'xxxxxx';
SMTP.Connect();
if SMTP.Authenticate then
begin
//setup mail message
MailMessage.From.Name := 'xxxxxx';
MailMessage.From.Address := 'info@xxxxxx.it';
MailMessage.Recipients.EMailAddresses := 'xxxxxx@gmail.com';
MailMessage.Subject := ledSubject.Text;
MailMessage.ContentType := 'multipart/mixed';
htmpart := TIdText.Create(MailMessage.MessageParts, nil);
htmpart.Body := Body.Lines;
htmpart.ContentType := 'text/html';
//send mail
try
try
SMTP.Send(MailMessage);
except on E:Exception do
StatusMemo.Lines.Insert(0, 'ERROR: ' + E.Message);
end;
finally
if SMTP.Connected then SMTP.Disconnect;
end;
end;
Probably I've found the problem. I look the message in 'original mode' I found in the header that google says 'MISSING ID' and I try to add this code:
MailMessage.MsgId := '1234567890@drinkmessage.it';
MailMessage.ExtraHeaders.Values['Message-Id'] := MailMessage.MsgId;
Now it seems to work fine.
thanks
Have you tried changing HeloName
and MailAgent
of IdSMTP
? If you use the same domain with PHPMailer, my guess is GMail considers emails coming from your application as spam because it doesn't detect/like the application which is sending them.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.