Bonjour,
Cela fait quelques heures que j'essaie d'utiliser le composant TIdSMTP pour envoyer un mail depuis le réseau de mon entreprise mais j'ai toujours un message d'erreur.
Le message d'erreur est "Enable to relay"
J'ai pu tester et vérifier les paramètres d'envoi avec un logiciel téléchargé sur Internet "SMTP Tester 1.0.1" donc je suis sur de ces paramètres.
Voici les paramètres que j'utilise:
Host : mail.xxx.fr
Port : 25
User : MyName@xxx.fr
Password : ...
Pas de SSL.
voici le source:
et la fiche:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 procedure TForm1.Button2Click(Sender: TObject); begin Screen.Cursor := crHourGlass; // Curseur sablier IdMessage1.Clear; // Efface l'entête et le corps du message IdMessage1.From.Text := Edit1.Text; // Adresse email de l'expediteur IdMessage1.ReplyTo.EMailAddresses := Edit1.Text; // Adresse email où le destinataire pourra répondre IdMessage1.Recipients.EMailAddresses := Edit2.Text; // Adresse email du destinataire IdMessage1.Date := Date; // Date de l'envoi du message IdMessage1.Subject := Edit4.Text; // Sujet du message IdMessage1.Priority := mpNormal; // Priorité du message IdMessage1.Body.Assign(Memo1.Lines);// Corps du message IdSMTP1.AuthType := satDefault; // Type d'authentification IdSMTP1.Host := 'mail.xxx.fr'; // Hôte (par exemple pour Free : smtp.free.fr) IdSMTP1.Port := 25; // Port (par exemple pour Free : 25) IdSMTP1.UserName := 'myname@xxx.fr'; // Nom d'utilisateur IdSMTP1.Password := 'pass'; // Mot de passe IdSMTP1.Connect; // Connexion try IdSMTP1.Send(IdMessage1); // Envoi du message finally IdSMTP1.Disconnect; // Déconnexion end; Screen.Cursor := crDefault; // Curseur par défaut end;
Merci
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166 object Form1: TForm1 Left = 315 Top = 119 ActiveControl = Button2 BorderIcons = [biSystemMenu, biMinimize] BorderStyle = bsSingle Caption = 'Envoyer un email avec TIdSMTP' ClientHeight = 443 ClientWidth = 323 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] OldCreateOrder = False Position = poScreenCenter PixelsPerInch = 96 TextHeight = 13 object GroupBox1: TGroupBox Left = 8 Top = 8 Width = 305 Height = 89 Caption = 'Param'#232'tres' TabOrder = 0 object Label1: TLabel Left = 8 Top = 24 Width = 56 Height = 13 Caption = 'Exp'#233'diteur :' end object Label2: TLabel Left = 8 Top = 56 Width = 62 Height = 13 Caption = 'Destinataire :' end object Edit1: TEdit Left = 80 Top = 21 Width = 209 Height = 21 TabOrder = 0 Text = 'myname@xxx.fr' end object Edit2: TEdit Left = 80 Top = 53 Width = 209 Height = 21 TabOrder = 1 Text = 'destinataire@free.fr' end end object GroupBox2: TGroupBox Left = 8 Top = 104 Width = 305 Height = 97 Caption = 'Attach'#233 TabOrder = 1 object Label3: TLabel Left = 8 Top = 28 Width = 37 Height = 13 Caption = 'Fichier :' end object Edit3: TEdit Left = 80 Top = 24 Width = 209 Height = 21 TabOrder = 0 end object Button1: TButton Left = 200 Top = 56 Width = 89 Height = 25 Caption = 'Parcourir...' TabOrder = 1 OnClick = Button1Click end end object GroupBox3: TGroupBox Left = 8 Top = 208 Width = 305 Height = 193 Caption = 'Message' TabOrder = 2 object Label4: TLabel Left = 8 Top = 24 Width = 30 Height = 13 Caption = 'Sujet :' end object Edit4: TEdit Left = 88 Top = 20 Width = 201 Height = 21 TabOrder = 0 Text = 'qsdfsqdf' end object Memo1: TMemo Left = 16 Top = 56 Width = 273 Height = 121 Lines.Strings = ( 'qsdfsdfsdqf') TabOrder = 1 end end object Button2: TButton Left = 64 Top = 410 Width = 81 Height = 25 Caption = 'Envoyer' TabOrder = 3 OnClick = Button2Click end object Button3: TButton Left = 176 Top = 410 Width = 81 Height = 25 Caption = 'Quitter' TabOrder = 4 OnClick = Button3Click end object OpenDialog1: TOpenDialog Filter = 'Tous les fichiers|*.*' Title = 'Parcourir...' Left = 96 Top = 160 end object IdSMTP1: TIdSMTP UseEhlo = False SASLMechanisms = <> Left = 16 Top = 160 end object IdMessage1: TIdMessage AttachmentEncoding = 'MIME' BccList = <> CCList = <> Encoding = meMIME FromList = < item end> Recipients = <> ReplyTo = <> ConvertPreamble = True Left = 56 Top = 160 end end
Partager