Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Mar 2006
    Posts
    200
    Thanks
    27
    Thanked 2 Times in 2 Posts

    php mail problems

    I've written a send to a friend script. When I tested it to my e-mail account, it always worked. I tried to other account and it's fine.

    The person I did it for has had no success...none of the e-mails have been received. How can I improve my script so it is received? Even hotmail seems to block it. It doesn't even end up in the junk box!!

    This is my code

    PHP Code:
    $friend_subject "You might be interested in this";

    $filename "send_to_friend.txt"
    $handle fopen ($filename"r"); 
    $contents fread ($handlefilesize ($filename));
    $contents str_replace("Xyour_nameX"$your_name$contents);
    $contents str_replace("Xyour_emailX"$your_email$contents);
    $contents str_replace("Xfriend_nameX"$friend_name$contents);
    $contents str_replace("Xfriend_emailX"$friend_email$contents);
    $contents str_replace("XmessageX"$message$contents);
    $contents str_replace("Xfriend_from_emailX"$friend_from_email$contents);
    $contents str_replace("XpageURLX"$pageURL$contents);
    mail("$friend_email","$friend_subject","$contents","From: $your_name <$friend_from_email>");
    fclose ($handle); 
    The text file simple says

    Hello Xfriend_nameX

    Xyour_nameX thought you might be interested in this website.

    XpageURLX

    Any ideas! Thanks guys!

    Nicky

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Its likely the server you are trying the script on doesn't support the php mail function or much less php.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    Regular Coder
    Join Date
    Mar 2006
    Posts
    200
    Thanks
    27
    Thanked 2 Times in 2 Posts
    But it does send out. I can receive it fine using my e-mail account...therefore the server must support it?

    Or do you mean the mail server of whoever is receiving it? My server does support it.

    Thanks,

    Nicky

  • #4
    Regular Coder
    Join Date
    Mar 2006
    Posts
    200
    Thanks
    27
    Thanked 2 Times in 2 Posts
    The server does support php. The script runs fine AND sends the mail. The problem is simply on the receiving end. Some e-mail accounts are receiving it, others aren't.

    I was looking for a way to improve the script so that it is received.

    Thanks

  • #5
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Some servers are blacklisted by hotmail and other mail clients due to others on the hosting site who may have abused the system by sending spam. What shows up as the from part when you send the email?
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #6
    Regular Coder
    Join Date
    Mar 2006
    Posts
    200
    Thanks
    27
    Thanked 2 Times in 2 Posts
    It appears as from whoever typed their name into my form. I use Outlook Express - it says its from the person's name but isn't coming up with an e-mail address. Maybe this is why?

    The site is hosted with a reputable company (Heart Internet). If it was blacklisted I would also have trouble sending e-mail out from my e-mail address surely? I don't have that problem.

    I think it's more to do with the information in the headers maybe? And the fact that it doesn't seem to be coming from any e-mail address....just someone's name.

    Thanks,

    Nicky

  • #7
    Regular Coder
    Join Date
    Mar 2006
    Posts
    200
    Thanks
    27
    Thanked 2 Times in 2 Posts
    Umm...I worked out why it wasn't sending an email address through..

    Watch this space...

    If this works I owe you a box of chocolates or something...

    THANKS!

  • #8
    Regular Coder
    Join Date
    Mar 2006
    Posts
    200
    Thanks
    27
    Thanked 2 Times in 2 Posts
    It still isn't sending to all e-mail accounts.

    I've tried to add header info

    PHP Code:
    $mail mail("$friend_email""$friend_subject""$contents",
         
    "From: $your_name <$your_email>\n" .
         
    "MIME-Version: 1.0\n " .
         
    "Content-type: text/html; charset=iso-8859-1" .     
         
    "X-Mailer: PHP/" phpversion()); 
    but to no avail.

    Someone suggested i try sending it through my smtp server to add the correct headers.

    Any ideas?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •