Jump to content

Smtp Email - How Do I?


khrishnabrown
 Share

Recommended Posts

I'm trying to send email using smtp from godaddy. Its a password recovery code, the user enters their email and a password is sent to them. But when I'm testing it it keeps giving me an error saying Warning: mail() [function.mail]: SMTP server response: 554 The message was rejected because it contains prohibited virus or spam content in D:\Hosting\4447297\html\send_password_ac.php on line 53Cannot send password to your e-mail addressI called godaddy and they said to make sure i dont have a link and other stuff and that their server info is relay-hosting.secureserver.net ( i dont have this in my code, dont know how to incorporate it)Here is my code<?$host="xxxxxxx"; // Host name $username="xxxxxx"; // Mysql username $password="xxxxxx"; // Mysql password $db_name="xxxxx"; // Database name //Connect to server and select databse.mysql_connect("$host", "$username", "$password")or die("cannot connect to server"); mysql_select_db("$db_name")or die("cannot select DB");// value sent from form $email_to=$_POST['email_to'];// table name $tbl_name=members; // retrieve password from table where e-mail$sql="SELECT password FROM $tbl_name WHERE email='$email_to'";$result=mysql_query($sql);// if found this e-mail address, row must be 1 row // keep value in variable name "$count" $count=mysql_num_rows($result);// compare if $count =1 rowif($count==1){$rows=mysql_fetch_array($result);// keep password in $your_password$your_password=$rows['password'];// ---------------- SEND MAIL FORM ---------------- // send e-mail to ...$to="$email_to"; // Your subject $subject="Your password here"; // From $header="from: khrishnabrown.info"; // Your message $messages="Your password is $your_password ";// send email $sentmail=mail($to,$subject,$messages,$header); }// else if $count not equal 1 else {echo "Email not found in database ";} // if your email succesfully sent if($sentmail){echo "Your Password Has Been Sent To Your Email Address.";}else {echo "Cannot send password to your e-mail address";}?>

Link to comment
Share on other sites

You can use ini_set to set the SMTP server if you need to:ini_set('smtp', 'xxx.xxx.com');
not realy sure how to use the ini_set. I placed it above the "//my mail section" as ini_set('smtp', 'relay-hosting.securederver.net'); but nothing. It kept saying that this line is where the error is " $sentmail=mail($to,$subject,$messages,$header); " Not sure why...
Link to comment
Share on other sites

That's the only line that communicates with the mail server, any mail server errors will come from that line. You can use ini_get to check what the current value is:echo 'SMTP: ' . ini_get('smtp');If you're still getting the 554 error then GoDaddy's mail server doesn't like your mail for some reason, or it doesn't like the headers in the mail. An error with the mail function means that the SMTP server (the sending server, not the receiving server) had a problem with the email. You actually won't be able to get error messages from the receiving server (such as mailbox not found). If you're having a problem with GoDaddy's mail server you'll need to find out what their policies are that your mail is apparently violating.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...