SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard
    Join Date
    Oct 2005
    Location
    London
    Posts
    1,678
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    cannot get email to send to hotmail

    Hi guy, I'm having problems with sending an email using php. I can get the mail to send to gmail but it only goes in to the junk folder and i cannot get it to send to hotmail at all. Heres the code i'm using....i've tried loads of combinations of /n and /n/n but it doesnt make a difference.

    Any chance someone could let me have a peek at some working code??

    Heres mine:

    PHP Code:
    $boundary md5(uniqid(time()));

    $headers  'From: registration@sites.com' "\n";
    $headers .= 'To: ' $email "\n";
    $headers .= 'Return-Path: registration@sites.com' "\n";
    $headers .= 'MIME-Version: 1.0' ."\n";
    $headers .= 'Content-Type: multipart/alternative; boundary="' $boundary '"' "\n\n";
    $headers .= $emailbody "\n"
    $headers .= '--' $boundary "\n";
    $headers .= 'Content-Type: text/plain; charset=ISO-8859-1' ."\n";
    $headers .= 'Content-Transfer-Encoding: 8bit'"\n\n";
    $headers .= $emailbody "\n"
    $headers .= '--' $boundary "\n";
    $headers .= 'Content-Type: text/HTML; charset=ISO-8859-1' ."\n";
    $headers .= 'Content-Transfer-Encoding: 8bit'"\n\n";
    $headers .= $emailbody "\n"
    $headers .= '--' $boundary "--\n";
    $subject 'Registration at www.site.com';

    mail(''$subject,''$headers); 

  2. #2
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,750
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, one common reason for things being marked as spam is that they server used to send email from is different than the website's domain. Is this the case for your mail server?

  3. #3
    SitePoint Wizard Hammer65's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln Nebraska
    Posts
    1,161
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The Hotmail spam filters are especially stringent about email message content and header structure. Hitting upon the right combination could take a lot of trial and error. Considering that your script appears to be hard coded for a specific project, I would recommend switching to using a pre-made email class such as PHPMailer or swiftmailer. This problem comes up practically every day on this board and the only time I would recommend a DIY approach to the problem is if you are willing to look at how some of the pre-made solutions do it though the source code. It is practically impossible for anyone here to trouble shoot the script when there are so many potential factors that could be causing it,
    Visit my blog
    PHP && Life
    for technology articles and musings.

  4. #4
    SitePoint Wizard
    Join Date
    Oct 2005
    Location
    London
    Posts
    1,678
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by chris_fuel View Post
    Well, one common reason for things being marked as spam is that they server used to send email from is different than the website's domain. Is this the case for your mail server?
    HI there,

    This may be the case.....i've now got messages being sent to all clients but they are all putting the message in to junk.....i really don't know how to find out if server is different from the domain.......any pointers?

  5. #5
    SitePoint Wizard Hammer65's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln Nebraska
    Posts
    1,161
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by elduderino View Post
    HI there,

    This may be the case.....i've now got messages being sent to all clients but they are all putting the message in to junk.....i really don't know how to find out if server is different from the domain.......any pointers?
    Look at the headers in the mail messages. I don't necessarily agree that the difference in domains will cause a problem. I have never seen that be the problem actually. The domain of the server that sends the mail, may be your host's. it won't be yoursite.com. The address you place in the "from" header will rarely be the same domain that the server is part of. If you are on shared hosting, it definitely won't be.
    Visit my blog
    PHP && Life
    for technology articles and musings.


Bookmarks

Posting Permissions

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