Reputation: 141
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 := '[email protected]';
SMTP.Password := 'xxxxxx';
SMTP.Connect();
if SMTP.Authenticate then
begin
//setup mail message
MailMessage.From.Name := 'xxxxxx';
MailMessage.From.Address := '[email protected]';
MailMessage.Recipients.EMailAddresses := '[email protected]';
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;
Upvotes: 3
Views: 2816
Reputation: 141
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 := '[email protected]';
MailMessage.ExtraHeaders.Values['Message-Id'] := MailMessage.MsgId;
Now it seems to work fine.
thanks
Upvotes: 4
Reputation: 4776
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.
Upvotes: 1