Jump to content

Not Sending Email....


djanim8

Recommended Posts

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);
?>

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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..

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

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);
?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.