Suchy Posted June 9, 2007 Share Posted June 9, 2007 I am having trouble with the email function, basicaly I am not getting any emails submited via the form. Here is my script: <?php if( in("send") != "send" ) {?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" METHOD="POST"> Name :<br><input name="name" type="text" id="name" size="35" /><br> Email :<br><input name="email" type="text" id="email" size="35" /><br> Question:<br> <textarea name="question" cols="27" rows="5" id="question" ></textarea> <br> <input type="submit" name="send" id="send" value="send" /> </form> <?php } else { ?> <strong>Email was submited</strong> <br> <a href="index.php">Previous page.</a> <?php } ?> The function is included on top of the page, before any html: <?php if(in("send")) { $name = $_POST['name']; $email = $_POST['email']; $question = $_POST['question']; $sendto = "________@hotmail.com"; $subject = "Question"; $headers = "From: " . $name; $ip=@$REMOTE_ADDR; $message = "Name: " . $name . "\n" . "Email : " . $email . "\n" . "Question : " . $question . "\n" . "IP : " . $ip; mail($sendto, $subject, $message, $headers); } ?> What is wrong with this ? Quote Link to comment https://forums.phpfreaks.com/topic/54890-email-form/ Share on other sites More sharing options...
Full-Demon Posted June 9, 2007 Share Posted June 9, 2007 You use in(), which isnt a function (according to php.net). Use if(isset($_POST['send'])) or something similair instead. Good luck. Full-Demon PS, for sending email, I would suggest you use swfit mailer, a library for sending mails, as the build in mail() is a bad function! Quote Link to comment https://forums.phpfreaks.com/topic/54890-email-form/#findComment-271523 Share on other sites More sharing options...
Suchy Posted June 10, 2007 Author Share Posted June 10, 2007 I noticed that when I change where the email will go to the form works 100%. I changed the destenation email address to administrator@____.org (my website) and I got every message submited via that form) But when the destenation email address is yahoo or hotmail I do not get any emails, even in the junk folders. I also have email fowarding on that administrator@____.org account so that every email sent there is fowarded to my hotmail account, but the emails generated by the form are not fowarded. What could be the reason for this ? Quote Link to comment https://forums.phpfreaks.com/topic/54890-email-form/#findComment-271656 Share on other sites More sharing options...
Full-Demon Posted June 10, 2007 Share Posted June 10, 2007 Perhaps your server is not connected, or something with SMTP is wrong... You should use swiftmailer! Not mail(), for the second time. mail() sends wrong headers and is very inefficient. FD Quote Link to comment https://forums.phpfreaks.com/topic/54890-email-form/#findComment-271839 Share on other sites More sharing options...
Suchy Posted June 10, 2007 Author Share Posted June 10, 2007 The problem eith swiftmailer is that it uses SMTP, and according to my providers website: Outgoing mail (SMTP) server: Use Your Internet Providers The problem is that I mainly use hotmail, which does not support SMTP. Is there any other way to fix this ? Quote Link to comment https://forums.phpfreaks.com/topic/54890-email-form/#findComment-271908 Share on other sites More sharing options...
jaikar Posted June 10, 2007 Share Posted June 10, 2007 may be you can use the following procedure get the PHPMailer, search in google to download it. put the files in a folder, create a file, say emailme.php, for mailing the contents inlcude the class.phpmailer.php on the first line instantiate the object like this $mail = new PHPMailer(); $mail->IsHTML(true); $mail->IsSMTP(); // telling the class to use SMTP $mail->Host = "localhost"; // SMTP server $mail->From = "from email address here"; $mail->FromName = 'display name here'; you can also copy the above code to the file after the inlcude code. store the values of the form using the Post methos to the variable or the array assign the content like this $mail->Body = 'content of the mail' then $mail->Subject = 'Subect here' then .. you are finished $mail->Send(); upto you to handle the error this is the perfect mailer ever !! ~J Quote Link to comment https://forums.phpfreaks.com/topic/54890-email-form/#findComment-271913 Share on other sites More sharing options...
Full-Demon Posted June 10, 2007 Share Posted June 10, 2007 The server from which you send the mail should have SMTP enabled, the server that receives the mail (ie gmail or hotmail etc), has nothing to do with the mail sending script of you. FD Quote Link to comment https://forums.phpfreaks.com/topic/54890-email-form/#findComment-271959 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.