Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP code required for email form via TCP
Old 09-10-2009, 09:26 AM PHP code required for email form via TCP
Average Talker

Posts: 28
Name: Rhowena MacCuish
Trades: 0
Hello

I wonder if anyone can help me find code to add to my html/PHP web email form which will allow for sending directly via a TCP?

I have been asked to add this code to make my webmail form be able to send the mails. I don't really know what I'm looking for so any help would be greatly appreciated.

Thank you!
rhowbust is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-10-2009, 09:59 AM Re: PHP code required for email form via TCP
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
TCP????

BTW the common protocols for mail are SMTP or POP3

And Webmail is read using a HTTP connection
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 09-10-2009, 10:45 AM Re: PHP code required for email form via TCP
Average Talker

Posts: 28
Name: Rhowena MacCuish
Trades: 0
I don't seem to have explained what I need very well. The server the website is hosted on does NOT have sendmail.
I need to find some PHP code that opens up a TCP connection on
port 25 to 127.0.0.1 and delivers the mail using raw SMTP.
Any clues??
rhowbust is offline
Reply With Quote
View Public Profile
 
Old 09-10-2009, 02:22 PM Re: PHP code required for email form via TCP
prasanthmj's Avatar
Experienced Talker

Posts: 42
Name: Prasanth
Trades: 0
Having an understanding of the Network Protocol Stack can help (also see: Internet_Protocol_Suite)
HTTP,SMTP,FTP etc are all Application Layer protocols on top of Network layer protocol TCP.

From your description it seems all that you have to do is to send email through SMTP.
The Pear library supports sending email through SMTP. You can do it with just a few lines of code.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
prasanthmj is offline
Reply With Quote
View Public Profile
 
Old 09-10-2009, 06:32 PM Re: PHP code required for email form via TCP
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Install "pear mail", and set up your wrapper.
http://www.phpmaniac.net/wiki/index....ing_using_SMTP
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 09-11-2009, 03:14 AM Re: PHP code required for email form via TCP
Junior Talker

Posts: 2
Name: gogoe joe
Trades: 0
Hi..
Regarding the post information i want to share this and also you can use that SMTP server also try this.....This PHP program generates an HTML form which you can use to create a TCP socket to a remote device and send data to it. This assumes the remote device accepts the socket connection on the port you choose to connect to......Thanks for sharing the post.....
<?php
/*

This script will display a html form.
On submit, the form will call itself and then check to see if the form element 'text1' is set.
If set a socket is made to the define IP address and port and the value of 'text1' is sent down the pipe.
The socket then disconnects and the form is redisplayed with the value of 'text1' in the html form's textbox.

IMPORTANT: If you are using an XPORT or COBOX change the connect mode to C4
so no IP address is being concatenating with the incoming message to the pic....unless you like it that way.
*/

$xportIP = "128.122.151.44"; //IP adddress to connect to
$port = 10001; // port number of IP

if ((isset($_POST["text1"])) && (isset($_POST["ip"])) && (isset($_POST["port"]))) { //if a filled textbox was submitted
$data = $_POST["text1"];
$ip = $_POST["ip"];
$port = $_POST["port"];

$fp = fsockopen ($ip, $port, $errno, $errstr, 30); //open the socket
if (!$fp) { //if the socket does not exist
echo "$errstr ($errno)n";
} else { //if the socket exists
fputs ($fp, $data); // send the data down the hole to the other end
echo "<font size='2' color='navy'>Message Sent: " . $_POST["text1"] . "</font>"; //confirmation message
fclose ($fp); //close the socket
}

}
?>

<!-- html form below -->

<html>
<body>

<form name="message" method="post" action="phpToSocketForm.php">
IP Address: <input type="text" name="ip" value="<?= $_POST["ip"]; ?>" size='15' maxlength='15'>
Port: <input type="text" name="port" value="<?= $_POST["port"]; ?>" size=5 maxlength=5> <br>

Data: <input type="text" name="text1" value="<?= $_POST["text1"]; ?>" size="6">
<input type="submit" value="Send It">
</form>

</body>
</html>
__________________

Please login or register to view this content. Registration is FREE
gogoejoe is offline
Reply With Quote
View Public Profile
 
Old 09-14-2009, 06:35 PM Re: PHP code required for email form via TCP
Average Talker

Posts: 28
Name: Rhowena MacCuish
Trades: 0
Thanks for the help guys. I have tried to put together the pieces of info, but it's not working for me. what I have now is the following:
<?php

RCPT TO: <enquiries@mywebsite.co.uk>
Mail From = $_REQUEST['email'] ;
$name = $_REQUEST['name'];
$comments = $_REQUEST['comments'] ;

if ((isset($_POST["name"])) && (isset($_POST["email"])) && (isset($_POST["comments"]))) { //if a filled textbox was submitted

> $fp = fsockopen("IP ADDRESS HERE", PORT NUMBER HERE, $errno, $errstr, 30);
> if (!$fp) {
> echo "$errstr ($errno)<br />\n";
> } else {
> $out = "GET / HTTP/1.1\r\n";
> $out .= "Host: IP ADDRESS HERE\r\n";
> $out .= "Connection: Close\r\n\r\n";
fputs ($fp, $name, $email, $comments); // send the data down the hole to the other end
>
> fwrite($fp, $out);
> while (!feof($fp)) {
> echo fgets($fp, 128);
> }

fclose ($fp); //close the socket
}

$success_page = 'contactsent.html'; //confirmation message page
//If there are NO mistakes in the field, user will redirect to this page
// Redirect to Home Page after message is sent
// SET $ctf_redirect_enable = 1; ON, $ctf_redirect_enable = 0; for OFF.
$ctf_redirect_enable = 1;
// Used for the delay timer once the message has been sent
$ctf_redirect_timeout = 5; // time in seconds to wait before loading another Web page
// Web page to send the user to after the time has expired
$ctf_redirect_url = 'index.html';

elseif (empty($name) || (empty($email) || empty($comments)) {

header( "Expires: Mon, 20 Dec 1998 01:00:00 GMT" );
header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" );
header( "Cache-Control: no-cache, must-revalidate" );
header( "Pragma: no-cache" );

?>

<html>
<head><title>error</title></head>
<body>
<h1>Error</h1>
<p>
Oops, it appears you forgot to enter either your
name, email address or your comments. Please press the BACK
button in your browser and try again.
</p>
</body>
</html>

<?php

}

if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {

[... direct user to an error page and quit ...]

}
?>

The form is on an HTML page form code as follows:

<form id="contact_form" name="contact_form" action="sendmailTCP.php" method="Post">
<label>Name</label>
<br />
<input name="name" type="text" size="50" />
<label><br />
Email Address</label>
<br />
<input name="email" type="text" size="50" />
<label><br />
Comments</label>
<br />
<textarea name="comments" cols="50" rows="10" dir="ltr" lang="en" xml:lang="en"></textarea>
</label>
<br />
<input name="Submit" type="submit" value="Submit" />
</p>
</form>

The PHP code used to send to the right response pages but they don't even do that anymore and still no email in the inbox.
If anyone can see what is wrong with the code I'd be very very gratefull.
rhowbust is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to PHP code required for email form via TCP
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.26036 seconds with 12 queries