<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Mail versenden über Sockets mit smtp]]></title><description><![CDATA[<p>Hi an alle,</p>
<p>ich versuche mich gerade daran Mails via Sockets und SMTP zu versenden.<br />
Ich melde mich vorher am POP3 Server an, da deer Provider SMTP after Pop verlangt.<br />
Danach versuche ich die Mail per smtp zu versenden.<br />
Bei Senden von MAIL FROM: <a href="mailto:mail@domain.tld" rel="nofollow">mail@domain.tld</a> bekomme ich auch noch ein OK.<br />
Nun gebe ich bei RCPT TO: <a href="mailto:mail@domain.tld" rel="nofollow">mail@domain.tld</a> meinen Account bei <a href="http://web.de" rel="nofollow">web.de</a> an und bekomme dort den Fehler: 554 Relay Access denied.</p>
<p>Laut RFC sollte es aber genauso funktionieren.</p>
<p>Hier mal der Code:</p>
<pre><code>st_SockkAddr.sin_family = AF_INET;
		st_SockkAddr.sin_port = htons(POP3_PORT);

		st_SockkAddr.sin_addr.s_addr = inet_addr(szHostname);

		success = connect(nSockId, (struct sockaddr*)&amp;st_SockkAddr, sizeof(st_SockkAddr)); 
		if(success &lt; 0)
		{
			int err = WSAGetLastError();
		}
		r_len = recv(nSockId, recvBuf, MAX_LENGTH, 0);
		recvBuf[r_len] = '\0';

		MessageBoxA(NULL, recvBuf, &quot;Empfangsbestätigung&quot;, MB_OK);
		//Get Mails

		//Logon User
		strcpy(sendBuf, &quot;USER name\r\n&quot;);
		s_len = send(nSockId, sendBuf, strlen(sendBuf), 0);

		r_len = recv(nSockId, recvBuf, MAX_LENGTH, 0);
		recvBuf[r_len] = '\0';

		MessageBoxA(NULL, recvBuf, &quot;Empfangsbestätigung&quot;, MB_OK);

		//LOGON Pass 
		strcpy(sendBuf, &quot;PASS password\r\n&quot;);
		s_len = send(nSockId, sendBuf, strlen(sendBuf), 0);
		r_len = recv(nSockId, recvBuf, MAX_LENGTH, 0);
		recvBuf[r_len] = '\0';

		MessageBoxA(NULL, recvBuf, &quot;Empfangsbestätigung&quot;, 0);

		closesocket(nSockId);
		nSockIdSMTP = socket(AF_INET, SOCK_STREAM, 0);

		strcpy(sendBuf, &quot;LIST\n&quot;);
		s_len = send(nSockId, sendBuf, strlen(sendBuf), 0);
		r_len = recv(nSockId, recvBuf, MAX_LENGTH, 0);

		recvBuf[r_len] = '\0';

		MessageBoxA(NULL, recvBuf, &quot;Empfangsbestätigung&quot;, MB_OK);

		//Send QUIT
		strcpy(sendBuf,&quot;QUIT\n&quot;);

		s_len = send(nSockId,sendBuf,strlen(sendBuf),0);

		r_len = recv(nSockId,recvBuf,MAX_LENGTH,0);
		recvBuf[r_len] = '\0';

		MessageBoxA(NULL, recvBuf, &quot;Empfangsbestätigung&quot;, MB_OK);

		//Connect to smtp
		st_SockkAddr.sin_family = AF_INET;
		st_SockkAddr.sin_port = htons(SMTP_PORT);

		st_SockkAddr.sin_addr.s_addr = inet_addr(&quot;127.0.0.1&quot;);
		success = connect(nSockId, (struct sockaddr*)&amp;st_SockkAddr, sizeof(st_SockkAddr)); //Verbinden zu SMTP
		if(success &lt; 0)
		{
			int err = WSAGetLastError();
		}
		r_len = recv(nSockId, recvBuf, MAX_LENGTH, 0);
		recvBuf[r_len] = '\0';

		//Say Hello to the domain
		strcpy(sendBuf,&quot;EHLO smtp.domain.de\r\n&quot;);

		s_len = send(nSockId,sendBuf,strlen(sendBuf),0);

		r_len = recv(nSockId,recvBuf,MAX_LENGTH,0);
		recvBuf[r_len] = '\0';

		MessageBoxA(NULL, recvBuf, &quot;Empfangsbestätigung&quot;, MB_OK);

		//Send from address
		strcpy(sendBuf ,  &quot;MAIL FROM: mail@domain.de\r\n&quot;);

		s_len = send(nSockId,sendBuf,strlen(sendBuf),0);

		r_len = recv(nSockId,recvBuf,MAX_LENGTH,0);
		recvBuf[r_len] = '\0';
		MessageBoxA(NULL, recvBuf, &quot;Empfangsbestätigung&quot;, MB_OK);

		//Send RCPT address
		strcpy(sendBuf,&quot;RCPT TO: &lt;name@web.de&gt;\r\n&quot;);

		s_len = send(nSockId,sendBuf,strlen(sendBuf),0);

		r_len = recv(nSockId,recvBuf,MAX_LENGTH,0);
		recvBuf[r_len] = '\0';
                  //Hierbei kommt nun der Fehler 554
		MessageBoxA(NULL, recvBuf, &quot;Empfangsbestätigung&quot;, MB_OK);

		// Send DATA
		strcpy(sendBuf,&quot;Subject: TestMail\r\n\r\n&quot;);
		s_len = send(nSockId,sendBuf,strlen(sendBuf),0);

		//Send body
		strcpy(sendBuf,&quot;TestMail\r\n.\r\n&quot;);

		s_len = send(nSockId,sendBuf,strlen(sendBuf),0);

		r_len = recv(nSockId,recvBuf,MAX_LENGTH,0);
		recvBuf[r_len] = '\0';

		MessageBoxA(NULL, recvBuf, &quot;Empfangsbestätigung&quot;, MB_OK);

		//Send QUIT
		strcpy(sendBuf,&quot;QUIT\n&quot;);

		s_len = send(nSockId,sendBuf,strlen(sendBuf),0);

		r_len = recv(nSockId,recvBuf,MAX_LENGTH,0);
		recvBuf[r_len] = '\0';

		MessageBoxA(NULL, recvBuf, &quot;Empfangsbestätigung&quot;, MB_OK);

		closesocket(nSockId);
</code></pre>
<p>Kann jemand mir sagen was ich falsch mache?</p>
<p>Gruß</p>
<p>Karsten</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/215856/mail-versenden-über-sockets-mit-smtp</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Apr 2026 18:08:34 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/215856.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 16 Jun 2008 12:23:05 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Mail versenden über Sockets mit smtp on Mon, 16 Jun 2008 12:23:05 GMT]]></title><description><![CDATA[<p>Hi an alle,</p>
<p>ich versuche mich gerade daran Mails via Sockets und SMTP zu versenden.<br />
Ich melde mich vorher am POP3 Server an, da deer Provider SMTP after Pop verlangt.<br />
Danach versuche ich die Mail per smtp zu versenden.<br />
Bei Senden von MAIL FROM: <a href="mailto:mail@domain.tld" rel="nofollow">mail@domain.tld</a> bekomme ich auch noch ein OK.<br />
Nun gebe ich bei RCPT TO: <a href="mailto:mail@domain.tld" rel="nofollow">mail@domain.tld</a> meinen Account bei <a href="http://web.de" rel="nofollow">web.de</a> an und bekomme dort den Fehler: 554 Relay Access denied.</p>
<p>Laut RFC sollte es aber genauso funktionieren.</p>
<p>Hier mal der Code:</p>
<pre><code>st_SockkAddr.sin_family = AF_INET;
		st_SockkAddr.sin_port = htons(POP3_PORT);

		st_SockkAddr.sin_addr.s_addr = inet_addr(szHostname);

		success = connect(nSockId, (struct sockaddr*)&amp;st_SockkAddr, sizeof(st_SockkAddr)); 
		if(success &lt; 0)
		{
			int err = WSAGetLastError();
		}
		r_len = recv(nSockId, recvBuf, MAX_LENGTH, 0);
		recvBuf[r_len] = '\0';

		MessageBoxA(NULL, recvBuf, &quot;Empfangsbestätigung&quot;, MB_OK);
		//Get Mails

		//Logon User
		strcpy(sendBuf, &quot;USER name\r\n&quot;);
		s_len = send(nSockId, sendBuf, strlen(sendBuf), 0);

		r_len = recv(nSockId, recvBuf, MAX_LENGTH, 0);
		recvBuf[r_len] = '\0';

		MessageBoxA(NULL, recvBuf, &quot;Empfangsbestätigung&quot;, MB_OK);

		//LOGON Pass 
		strcpy(sendBuf, &quot;PASS password\r\n&quot;);
		s_len = send(nSockId, sendBuf, strlen(sendBuf), 0);
		r_len = recv(nSockId, recvBuf, MAX_LENGTH, 0);
		recvBuf[r_len] = '\0';

		MessageBoxA(NULL, recvBuf, &quot;Empfangsbestätigung&quot;, 0);

		closesocket(nSockId);
		nSockIdSMTP = socket(AF_INET, SOCK_STREAM, 0);

		strcpy(sendBuf, &quot;LIST\n&quot;);
		s_len = send(nSockId, sendBuf, strlen(sendBuf), 0);
		r_len = recv(nSockId, recvBuf, MAX_LENGTH, 0);

		recvBuf[r_len] = '\0';

		MessageBoxA(NULL, recvBuf, &quot;Empfangsbestätigung&quot;, MB_OK);

		//Send QUIT
		strcpy(sendBuf,&quot;QUIT\n&quot;);

		s_len = send(nSockId,sendBuf,strlen(sendBuf),0);

		r_len = recv(nSockId,recvBuf,MAX_LENGTH,0);
		recvBuf[r_len] = '\0';

		MessageBoxA(NULL, recvBuf, &quot;Empfangsbestätigung&quot;, MB_OK);

		//Connect to smtp
		st_SockkAddr.sin_family = AF_INET;
		st_SockkAddr.sin_port = htons(SMTP_PORT);

		st_SockkAddr.sin_addr.s_addr = inet_addr(&quot;127.0.0.1&quot;);
		success = connect(nSockId, (struct sockaddr*)&amp;st_SockkAddr, sizeof(st_SockkAddr)); //Verbinden zu SMTP
		if(success &lt; 0)
		{
			int err = WSAGetLastError();
		}
		r_len = recv(nSockId, recvBuf, MAX_LENGTH, 0);
		recvBuf[r_len] = '\0';

		//Say Hello to the domain
		strcpy(sendBuf,&quot;EHLO smtp.domain.de\r\n&quot;);

		s_len = send(nSockId,sendBuf,strlen(sendBuf),0);

		r_len = recv(nSockId,recvBuf,MAX_LENGTH,0);
		recvBuf[r_len] = '\0';

		MessageBoxA(NULL, recvBuf, &quot;Empfangsbestätigung&quot;, MB_OK);

		//Send from address
		strcpy(sendBuf ,  &quot;MAIL FROM: mail@domain.de\r\n&quot;);

		s_len = send(nSockId,sendBuf,strlen(sendBuf),0);

		r_len = recv(nSockId,recvBuf,MAX_LENGTH,0);
		recvBuf[r_len] = '\0';
		MessageBoxA(NULL, recvBuf, &quot;Empfangsbestätigung&quot;, MB_OK);

		//Send RCPT address
		strcpy(sendBuf,&quot;RCPT TO: &lt;name@web.de&gt;\r\n&quot;);

		s_len = send(nSockId,sendBuf,strlen(sendBuf),0);

		r_len = recv(nSockId,recvBuf,MAX_LENGTH,0);
		recvBuf[r_len] = '\0';
                  //Hierbei kommt nun der Fehler 554
		MessageBoxA(NULL, recvBuf, &quot;Empfangsbestätigung&quot;, MB_OK);

		// Send DATA
		strcpy(sendBuf,&quot;Subject: TestMail\r\n\r\n&quot;);
		s_len = send(nSockId,sendBuf,strlen(sendBuf),0);

		//Send body
		strcpy(sendBuf,&quot;TestMail\r\n.\r\n&quot;);

		s_len = send(nSockId,sendBuf,strlen(sendBuf),0);

		r_len = recv(nSockId,recvBuf,MAX_LENGTH,0);
		recvBuf[r_len] = '\0';

		MessageBoxA(NULL, recvBuf, &quot;Empfangsbestätigung&quot;, MB_OK);

		//Send QUIT
		strcpy(sendBuf,&quot;QUIT\n&quot;);

		s_len = send(nSockId,sendBuf,strlen(sendBuf),0);

		r_len = recv(nSockId,recvBuf,MAX_LENGTH,0);
		recvBuf[r_len] = '\0';

		MessageBoxA(NULL, recvBuf, &quot;Empfangsbestätigung&quot;, MB_OK);

		closesocket(nSockId);
</code></pre>
<p>Kann jemand mir sagen was ich falsch mache?</p>
<p>Gruß</p>
<p>Karsten</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1530070</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1530070</guid><dc:creator><![CDATA[CrazyPlaya]]></dc:creator><pubDate>Mon, 16 Jun 2008 12:23:05 GMT</pubDate></item><item><title><![CDATA[Reply to Mail versenden über Sockets mit smtp on Wed, 18 Jun 2008 09:55:28 GMT]]></title><description><![CDATA[<p>So ich habe jetzt rausgefunden, dass ich dass mit SMTP-Auth machen muss.<br />
Dazu habe ich meinem Quellcode die folgenden Zeilen hinzugefügt.</p>
<pre><code>//Send AUTH Login
		strcpy(sendBuf,&quot;AUTH LOGIN\r\n&quot;);
		s_len = send(nSockIdSMTP,sendBuf,strlen(sendBuf),0);
		r_len = recv(nSockIdSMTP,recvBuf,MAX_LENGTH,0);
		recvBuf[r_len] = '\0';
		MessageBoxA(NULL, recvBuf, &quot;Empfangsbestätigung&quot;, MB_OK);

		//send Username
		strcpy(sendBuf,&quot;myusername\r\n&quot;);
		s_len = send(nSockIdSMTP,sendBuf,strlen(sendBuf),0);
		r_len = recv(nSockIdSMTP,recvBuf,MAX_LENGTH,0);
		recvBuf[r_len] = '\0';
		MessageBoxA(NULL, recvBuf, &quot;Empfangsbestätigung&quot;, MB_OK);

                  //send password
		strcpy(sendBuf,&quot;mypassword\r\n&quot;);
		s_len = send(nSockIdSMTP,sendBuf,strlen(sendBuf),0);
		r_len = recv(nSockIdSMTP,recvBuf,MAX_LENGTH,0);
		recvBuf[r_len] = '\0';
		MessageBoxA(NULL, recvBuf, &quot;Empfangsbestätigung&quot;, MB_OK);
</code></pre>
<p>Bis nach Übergabe des Usernamens läuft auch alles korrekt. Nach senden des Passwortes bekomme ich die Meldung &quot;535 authentification failed&quot;. Username und Passwort sind aber definitiv korrekt angegeben.</p>
<p>Was mache ich hier immer noch falsch ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1531386</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1531386</guid><dc:creator><![CDATA[CrazyPlaya]]></dc:creator><pubDate>Wed, 18 Jun 2008 09:55:28 GMT</pubDate></item><item><title><![CDATA[Reply to Mail versenden über Sockets mit smtp on Wed, 18 Jun 2008 09:56:30 GMT]]></title><description><![CDATA[<p>Falsches Forum.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1531390</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1531390</guid><dc:creator><![CDATA[Dipl.Inf.Student]]></dc:creator><pubDate>Wed, 18 Jun 2008 09:56:30 GMT</pubDate></item><item><title><![CDATA[Reply to Mail versenden über Sockets mit smtp on Wed, 18 Jun 2008 10:27:25 GMT]]></title><description><![CDATA[<p>Username und Passwort sollten base64 codiert sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1531403</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1531403</guid><dc:creator><![CDATA[Scheppertreiber]]></dc:creator><pubDate>Wed, 18 Jun 2008 10:27:25 GMT</pubDate></item><item><title><![CDATA[Reply to Mail versenden über Sockets mit smtp on Wed, 18 Jun 2008 10:29:08 GMT]]></title><description><![CDATA[<p>Schon probiert, dann gibts nen Time Out</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1531405</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1531405</guid><dc:creator><![CDATA[CrazyPlaya]]></dc:creator><pubDate>Wed, 18 Jun 2008 10:29:08 GMT</pubDate></item><item><title><![CDATA[Reply to Mail versenden über Sockets mit smtp on Wed, 18 Jun 2008 13:55:50 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/19487">@Scheppertreiber</a>: Du hattest vollkommen recht. Nur das man das \r\n nicht mit encoden sollte:D</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1531619</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1531619</guid><dc:creator><![CDATA[CrazyPlaya]]></dc:creator><pubDate>Wed, 18 Jun 2008 13:55:50 GMT</pubDate></item><item><title><![CDATA[Reply to Mail versenden über Sockets mit smtp on Wed, 18 Jun 2008 16:43:18 GMT]]></title><description><![CDATA[<p>CrazyPlaya schrieb:</p>
<blockquote>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/19487">@Scheppertreiber</a>: Du hattest vollkommen recht. Nur das man das \r\n nicht mit encoden sollte:D</p>
</blockquote>
<p>Oh F... - das sind diese Macken die am Schwierigsten zu finden sind *fg*</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1531749</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1531749</guid><dc:creator><![CDATA[Scheppertreiber]]></dc:creator><pubDate>Wed, 18 Jun 2008 16:43:18 GMT</pubDate></item><item><title><![CDATA[Reply to Mail versenden über Sockets mit smtp on Wed, 18 Jun 2008 16:51:02 GMT]]></title><description><![CDATA[<p>ich hoffe dir ist bewußt das recv nicht immer eine komplette Zeile liest^^</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1531753</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1531753</guid><dc:creator><![CDATA[$]]></dc:creator><pubDate>Wed, 18 Jun 2008 16:51:02 GMT</pubDate></item></channel></rss>