SMTP connect instead of using mail()
06-24-03, 05:46 PM
Newbie Coder
Join Date: Jun 2003
Location: else where
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
SMTP connect instead of using mail()
hi there !
please read this first and after maybe you can "light me" :
<?php
$smtp_server = "smtpserver.com";
$port = 25;
$mydomain = "mydomain.com";
$username = "username"; $password = "password";
$sender = "sender email";
$recipient = "email that the content will be sent to";
$subject = "the subject";
$content = "the message";
// SMTP connection
$handle = fsockopen($smtp_server,$port);
fputs($handle, "EHLO $mydomain\r\n");
// SMTP authorization
fputs($handle, "AUTH LOGIN\r\n");
fputs($handle, base64_encode($username)."\r\n");
fputs($handle, base64_encode($password)."\r\n");
// Send out the e-mail
fputs($handle, "MAIL FROM:<$sender>\r\n");
fputs($handle, "RCPT TO:<$recipient>\r\n");
fputs($handle, "DATA\r\n");
fputs($handle, "To: $recipient\n");
fputs($handle, "Subject: $subject\n\n");
fputs($handle, "$content\r\n");
fputs($handle, ".\r\n");
// Close connection to SMTP server
fputs($handle, "QUIT\r\n");
?>
ok
now i want to ask you how do i pass information from a html form to the php script, i mean to the "sender" , "subject" , "content" ?
i know there is a "post", using $get method, but i don't know how to do it.
pls help me !
06-24-03, 06:06 PM
The Freshmaker
Join Date: Jun 2003
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Let me get this straight... you post a script that talks directly to an SMTP server....
and you're asking how to get variables from a form
Wow. That's wierd.
__________________
Author of <a href=http://www.hotscripts.com/Detailed/18290.html target=_blank>ezSQL</a> (makes life soooo easy when working with databases)
06-25-03, 01:51 AM
Wannabe Coder
Join Date: Jun 2003
Location: Sydney, Australia
Posts: 208
Thanks: 0
Thanked 0 Times in 0 Posts
jv2222, plese only make useful posts...
Here is a simple form page..
06-25-03, 05:29 PM
Newbie Coder
Join Date: Jun 2003
Location: else where
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
hey, i resolved that problem above...
but i'm into a big shit:
the smtp mail works fine, but there is a problem, and i think it's about the lenght of the messege being send, the size of it...
i tried to send a message both with $_GET and $_POST methods, but using the $_GET the browser(IE) didn't take the command, when the message was to long, and with $_POST, the message looked like sent, but there was nothing coming in my inbox...
do you have any ideea ?
what do you thing i should do ?
06-25-03, 05:36 PM
Newbie Coder
Join Date: Jun 2003
Location: else where
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
hey, jv2222, thanks for your help !
if you would be the single really good programmer on this earth, then you'd be the only one...
Last edited by spinicrus; 06-25-03 at 05:41 PM .
06-26-03, 02:32 AM
The Freshmaker
Join Date: Jun 2003
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
After the for (in your php script) put this. It might help. It's a print out of all the variables as they were recieved by php.
print_r($_POST);
__________________
Author of <a href=http://www.hotscripts.com/Detailed/18290.html target=_blank>ezSQL</a> (makes life soooo easy when working with databases)
06-26-03, 09:56 AM
Newbie Coder
Join Date: Jun 2003
Location: else where
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
click this first:
http://www.metalborn.ro/capture.gif
this is the original text:
it is not becouse of the lenght of the message... it's about the breakets... there are interpreted wrong by the php... i read something like this.... so watch this :
"After the for (in your php script) put this. It might help. It's a print out of all the variables as they were recieved by php."
Last edited by spinicrus; 06-26-03 at 10:07 AM .
06-27-03, 06:30 PM
Operations Support Develo
Join Date: Jun 2003
Location: Rivonia, South Africa
Posts: 111
Thanks: 0
Thanked 0 Times in 0 Posts
I'd change this script to the following...
PHP Code:
<?php
$smtp_server = "smtpserver.com" ;
$port = 25 ;
$mydomain = "mydomain.com" ;
$username = "username" ;
$password = "password" ;
$sender = "sender email" ;
if (ISSet( $_REQUEST [ "recipient" ]))
{
$recipient = $_REQUEST [ "recipient" ];
}
else
{
Die( "Recipient is a required field..." );
}
if (ISSet( $_REQUEST [ "subject" ]))
{
$subject = $_REQUEST [ "subject" ];
}
else
{
$subject = "" ;
}
if (ISSet( $_REQUEST [ "content" ]))
{
$content = $_REQUEST [ "content" ];
}
else
{
Die( "Content is a required field..." );
}
// SMTP connection
$handle = fsockopen ( $smtp_server , $port );
fputs ( $handle , "EHLO " . $mydomain . "\r\n" );
// SMTP authorization
fputs ( $handle , "AUTH LOGIN\r\n" );
fputs ( $handle , base64_encode ( $username ). "\r\n" );
fputs ( $handle , base64_encode ( $password ). "\r\n" );
// Send out the e-mail
fputs ( $handle , "MAIL FROM:<" . $sender . ">\r\n" );
fputs ( $handle , "RCPT TO:<" . $recipient . ">\r\n" );
fputs ( $handle , "DATA\r\n" );
fputs ( $handle , "To: " . $recipient . "\n" );
fputs ( $handle , "Subject: " . $subject . "\n\n" );
fputs ( $handle , $content . "\r\n" );
fputs ( $handle , ".\r\n" );
// Close connection to SMTP server
fputs ( $handle , "QUIT\r\n" );
?>
The form as per Chris
I don't know if this will help at all...
__________________
Till We Meet Again...
Clifford W. Hansen
Aspivia (Pty) Ltd
"We Have Seen Strange Things Today!" Luke 5:26
06-27-03, 08:33 PM
Newbie Coder
Join Date: Jun 2003
Location: else where
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
hey, that's a good ideea, i understand what you want with that... it might work...
tnx a lot !
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off