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 10 of 10
  1. #1
    Regular Coder
    Join Date
    Dec 2006
    Posts
    185
    Thanks
    17
    Thanked 0 Times in 0 Posts

    Sending Email with PHP

    HI

    I tried sending mail with php's mail function and i filled in the From: option in for the header but when ever i send an email to gmail and im assuming other webbased email its blocked by the email or is put in the spam folder does anyone know how to make it so emails are sent to the inbox? Im assuming i am missing something in the header option


    Thanks

  • #2
    Regular Coder ArcticFox's Avatar
    Join Date
    Jan 2004
    Location
    Vostok Station, AQ
    Posts
    602
    Thanks
    35
    Thanked 3 Times in 3 Posts

    Internet Explorer

    Let's see your code.
    <div> - putting your mind in a box since 1997

  • #3
    Regular Coder
    Join Date
    Dec 2006
    Posts
    185
    Thanks
    17
    Thanked 0 Times in 0 Posts

    Ok

    Heres my code:


    PHP Code:
    $to "johndoe@gmail.com";
    $subject "PHP Is Great";
    $body "PHP is one of the best scripting languages around";
    $headers "From: johndoe@example.com\n";
    mail($to,$subject,$body,$headers);
    echo 
    "Mail sent to $to"

  • #4
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    use if statements to see if the mail sent!

    PHP Code:

    $to 
    "johndoe@gmail.com";
    $subject "PHP Is Great";
    $body "PHP is one of the best scripting languages around";
    $headers "From: johndoe@example.com\n";
    mail($to,$subject,$body,$headers);
    if (
    mail($to,$subject,$body,$headers)) 
    {
    echo 
    "Mail sent to $to";  
    }
    else 
    {
    echo 
    "Sorry Server Error";


  • #5
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    I think the problem is that emails are getting marked as spam.

    If you google for this I think there's quite a bit of information.

    One of the key things that a spam filter will look at is the headers. There's a few headers in there that will ensure a higher chance of it going to the inbox.

    Besides that this is just a result from people getting upset about spam.

    You just need to tell people they have to add your email address to the allowed list.

  • #6
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    Quote Originally Posted by aedrin View Post
    I think the problem is that emails are getting marked as spam.

    If you google for this I think there's quite a bit of information.

    One of the key things that a spam filter will look at is the headers. There's a few headers in there that will ensure a higher chance of it going to the inbox.

    Besides that this is just a result from people getting upset about spam.

    You just need to tell people they have to add your email address to the allowed list.
    Correct!
    But first is the mail being sent? if not its a server error

  • #7
    Regular Coder
    Join Date
    Dec 2006
    Posts
    185
    Thanks
    17
    Thanked 0 Times in 0 Posts
    Yes the emails are being sent but they are forwarded to the spam folder on the person of the recieving end and could you give a few link suggestions or usefull keywords to type in google im stuck
    Last edited by thekevin07; 02-28-2007 at 07:38 PM.

  • #8
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,036
    Thanks
    2
    Thanked 316 Times in 308 Posts
    Here is a recent thread that covers most of the common things you need to get right in order for an email to not be automatically ranked as spam - PHP mail issue - Mail not reciving on all providers

    The short version -

    Check that your server and mail server "look" correct to the receiving mail server - check at www.dnsreport.com

    Check if your mail server appears on spam databases - check at www.dnsstuff.com

    Make sure that your email is a valid email. Does the domain in the from address exist and match your sending mail server or does the DNS server for that from domain have an SPF record that authorizes your mail server to send for it...

    Make sure the content of the email does not look like spam. Short subject or message bodies with "spam" like words will be voted as spam. Spam like names in the From: address will also get votes for being spam.

    This and a lot more information about how the major ISP's treat incomming email can be found at the "postmaster" web pages that they all have -

    http://postmaster.aol.com/

    http://postmaster.msn.com/

    http://help.yahoo.com/l/us/yahoo/mai...use/index.html
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #9
    Regular Coder
    Join Date
    Dec 2006
    Posts
    185
    Thanks
    17
    Thanked 0 Times in 0 Posts
    THANK YOU

    I am using googles smtp server to send email and i dont suppose you know of a way to get a domain out of a spam list?

  • #10
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    change subject and headers, thats a big hitter for spam filters


  •  

    Posting Permissions

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