djanim8 Posted July 29, 2007 Share Posted July 29, 2007 I've searched through the forums to find out if I could get a resolution to this problem, added some code in here from the forums, but it still won't send an email through the website.. can someone take a look a this and see if you can figure out why? thanks <?PHP // INI Settings // ini_set(sendmail_from,$companyInfo['email']); ini_set(SMTP,"localhost"); ini_set(smtp_port,"25"); // Gather Email Info // $message = "Emailed From: ".$_POST['txtName']."<br><br>"; $message .= "Message Below:<br>".stripslashes(nl2br($_POST['txtMessage'])); $to = $companyInfo['name']." <".$companyInfo['email'].">"; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "To: ".$to."\r\n"; $headers .= "From: ".$_POST['txtName']." <".$_POST['txtEmail'].">\r\n"; mail($to,$_POST['txtSubject'],$message,$headers); //Send the email to the client $to = $_POST['txtName']." <".$_POST['txtEmail'].">"; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "To: ".$to."\r\n"; $headers .= "From: ".$companyInfo['name']." <".$companyInfo['email'].">\r\n"; mail($to,"Copy of your Email to .$companyInfo['name'],stripslashes(nl2br($_POST['txtMessage'])),$headers); ?> Quote Link to comment Share on other sites More sharing options...
AndyB Posted July 29, 2007 Share Posted July 29, 2007 Do you mean the code generates errors, or do you mean the emails (apparently) never arrive? Quote Link to comment Share on other sites More sharing options...
djanim8 Posted July 29, 2007 Author Share Posted July 29, 2007 it doesn't display any errors.. the emails just never arrive Quote Link to comment Share on other sites More sharing options...
AndyB Posted July 29, 2007 Share Posted July 29, 2007 Few questions. I assume that $companyInfo['email'] and $companyInfo['name'] are really defined somewhere in your actual script? I assume that that the mailform is method="post" and that all variables in the form have the exact same name as your POSTed variables. Does this all fail when using a true domain mail address, i.e. not a 'free' email address, and running on a live server? Does anything show up in a 'spam' folder? Quote Link to comment Share on other sites More sharing options...
djanim8 Posted July 29, 2007 Author Share Posted July 29, 2007 yea, the company's name and email is pulled from a database above in the script. All the fields are the same (checked those first) and it is a post.. for the "true domain mail address" do you mean instead of setting it to "localhost" you set it to the .com domain? nothing shows up in spam.. for some reason it doesn't send at all.. Quote Link to comment Share on other sites More sharing options...
djanim8 Posted July 29, 2007 Author Share Posted July 29, 2007 I did just change it from localhost to the domain (future-sounds.com) but it gave me an error about authenticity? Quote Link to comment Share on other sites More sharing options...
AndyB Posted July 29, 2007 Share Posted July 29, 2007 I meant using a real domain as the email to and email from addresses, i.e. no hotmail or other junk. Could be your php.ini settings but I'm in over my head with those - I just use mail() without all the smtp stuff (for which I would have assumed localhost was fine). Quote Link to comment Share on other sites More sharing options...
TheFilmGod Posted July 29, 2007 Share Posted July 29, 2007 Try this on your server. Its possible you don't have the proper mail sending out extensions installed. This is code from my server that WORKS. If this works it means you do have it properly installed and thus need to look into your code more closely. Insert your email address in $mail_to! <?php // Send Email to confirm registration $mail_to=YOUR EMAIL ADDRESS HERE; $mail_sub="Confirmed Registration"; // You must set a sender through message header $MsgHeader="From: Northern Knight"; // These two lines are required $MsgHeader .= "MIME-Version: 1.0\n"; $MsgHeader .= "Content-type: text/html; charset=us-ascii\n"; // Message body is HTML $MsgBody = " <html> <head> <title>Wwpknights Confirmed Registration</title> </head> <body> <h1>Confirmed Registration</h1> <p>Thank you for registering with wwpknights.com. You are now welcome to login and enjoy the benefits as a user. If you need help at any time please write to contact@thefilmgod.com or fill out a contact form on the website.</p> <p> Sincerely,<br> <strong>NorthernKnight</strong> </p> </body> </html>"; // Actual sending operation mail($mail_to, $mail_sub, $MsgBody, $MsgHeader); ?> Quote Link to comment Share on other sites More sharing options...
djanim8 Posted July 29, 2007 Author Share Posted July 29, 2007 AndyB: yea its the real domain, it pulls the email from a database and returns info@future-sounds.com TheFilmGod: I tried it here: http://www.future-sounds.com/newsite/email_test.php inserting my email addres (james@creativedynamix.net) and I didn't receive anything.. Quote Link to comment Share on other sites More sharing options...
TheFilmGod Posted July 29, 2007 Share Posted July 29, 2007 Quote from my PHP AND MYSQL BY EXAMPLE, written by Ellie Quigley with Marko Gargenta; Prentice Hall, Copyright 2006.................. "For a php script to be able to send email it must be able to talk to a mail server that is willing to accept its request and deliver the email to the internet. A mail server, sometimes referred to as the simple mail transfer protocol (SMTP) server, is a software process that takes an email message for dilvery and forwards it to other mail server on the internet until the message reaches its final destination. To set up PHP to talk to your mail server, first you must know the IP or the internet address of your mail server. Typically something like mail.domain.net wois it. You then need to update the SMTP property in the php.ini file to point to this server. The default value of this property is localhost. In the past, any mail server would accept a request to deliver any message by anyone to anyone. However, because spammers abused this loophole, almost all mail servers are pretotected now, the most common protection being a mail server, provided by an ISP, that will only accept message oringinating from its own network. Quote Link to comment Share on other sites More sharing options...
djanim8 Posted July 29, 2007 Author Share Posted July 29, 2007 I tried setting it to mail.future-sounds.com (I THINK this might be the incoming/outgoing mail server, but my client is home at the moment, so I'm just guessing...) It says it sent it to the info mail... but when it tries to send a copy of the email to person sending the email (in this case, james @ creativedynamix.net) I get this: Warning: mail() [function.mail]: SMTP server response: 503 This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server. in sendemail.php on line 63 Line 63 has the mail() function to send it to the user. Quote Link to comment Share on other sites More sharing options...
djanim8 Posted July 30, 2007 Author Share Posted July 30, 2007 am I not going to be able to send emails to the user because the domain is different? Quote Link to comment 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.