Jump to content

[SOLVED] PHP mail() function with my server


Reaper0167

Recommended Posts

my hosting server will not allow me to use the mail() function. I get this error message.

 

Warning: mail() [function.mail]: SMTP server response: 554 The message was rejected because it contains prohibited virus or spam content

 

Variables that I'm using.

$user_in = $_POST['pin_find'];

$user_email = $_POST['email_find'];

$to = $user_email;

$subject = 'Username Request';

$from = 'mysite.com';

$message = 'Thank you for being a member of mysite.com  Your username is';

 

<?php
if(mail($to, $subject, $message, "From: $from"))
{
    echo "Email sent";
}
?>

 

Is there anything else I could do to make this work? I would like to leave it as a PHP page.

Link to comment
Share on other sites

Short email messages that contain URL's are sometimes voted as spam by spam filtering software. You might consider lengthening the message body (a disclaimer about it being sent by an automated system and if the recipient did not cause it to be sent perhaps notify the site administrator...). About the only other possibility based on what you have posted is that your mail server has your domain on a spam list and won't send any email with it in the message body or the From: address.

 

You should probably be asking your web host the reason why the mail server is returning that response for the subject, message, and from address that you are using to make up the email. He can tell you exactly, we can only guess.

Link to comment
Share on other sites

Make sure you're sending all the correct headers (the full FROM and such)

 

Are you by chance on GoDaddy? I've heard of a lot of people that use GoDaddy hosting having to contact them to take their site off a spam list to send out emails.

Link to comment
Share on other sites

Ok, I got it to work. All I did is take out the $from variable from the script(which is mentioned in my first post) And I tested it with my personal email. The subject of the email comes up as webmaster@secureserver.net  Which godaddy said that is them. How can I still use the $from in my script? Is that with the header info you were talking about?

Link to comment
Share on other sites

I put my hosting server email, but the name is still the webmaster from godaddy.

<?php
include "connection.php";

$user_in = $_POST['pin_find'];
$user_email = $_POST['email_find'];
$to = $user_email;
$subject = 'Username Request';
$from = 'myname@mysite.com';
$message = 'Thank you for being a member Your username is';

$sql = "SELECT username FROM members WHERE secret_code = '$user_in' AND email = '$user_email' LIMIT 1";
$result = mysql_query($sql);
$count=mysql_num_rows($result);

if($count == 1)
{
    if(mail($to, $subject, $message, $from)) 
    {
        echo "Email sent";
    }
    else 
    {
        echo "Email not sent";
    }
}
?>

 

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.