Solved

I cant receive emails sent from the php script

Posted on 2006-11-15
13
226 Views
Last Modified: 2007-01-02
hi i had a php script installed on my website's contact page but i cant receive emails sent from this php script. althogh i get a message saying information sent successfully on the website but i cant find the email in my mail box anywhere.. my coding of the mail portion is as follows

 if ($send != "no") {
   
        // this is the info that comes on the email when it's ok to send!
        $msg = "E-MAIL SENT FROM http://www.yoursite.net/contact/\n";
        $msg .= "Sender's Name:    $sender_name\n";
        $msg .= "Sender's E-Mail:  $sender_email\n";
          $msg .= "Sender's  Company:  $sender_company\n";
        $msg .= "Message:          $message\n\n";    
       /* $to = "ryulite04@gmail.com";*/
        $subject = "Information";
        $mailheaders = "From: Information\n \n".
                                    "Reply-To: $sender_email\n\n".
                                    'MIME-Version: 1.0' . "\r\n".
                                    'Content-type: text/html; charset=iso-8859-1' . "\r\n";

        mail("ryulite04@gmail.com", $subject, $msg, $mailheaders);
        echo " <div align=\"center\"><table  width=\"400\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
    echo " <tr><td height=\"20\" colspan=2 >&nbsp;</td></tr>";
     
is there anything wrong with the way i wrote the code?
0
Comment
Question by:ryulite
  • 6
  • 4
13 Comments
 
LVL 19

Accepted Solution

by:
VoteyDisciple earned 250 total points
ID: 17953094
Two things.
1.  You have, in a couple places, \n\n.  That's incorrect.  All headers in e-mail always end with \r\n (it doesn't matter what platform you're using). Inside the body of the message you're free to write anything you like, but in the headers it's always \r\n.

2.  You've got a header that reads "From: Information"  That's not a valida ddress, so I wouldn't expect your server to pass it along.

0
 

Author Comment

by:ryulite
ID: 17953143
so for the header that reads from information.. what would be the best way to write it? is it my own email address or?
0
 

Author Comment

by:ryulite
ID: 17953156
can i put From:Information as From:www.makemoneywithlynn.biz or From: $sender_email
0
 

Author Comment

by:ryulite
ID: 17953180
i tried From: $sender_email but no avail
0
 
LVL 19

Expert Comment

by:VoteyDisciple
ID: 17953184
The From: is the genuine From: header that will show up on the incoming mail, so it can't be just a domain name, and I'd recommend against using $sender_email for semantic reasons (though that would certainly work).  

If possible, use some account on your e-mail server that can receive mail (even if nobody's ever going to look at it) so you have the option fo doing something like bouncing back messages that come there (in case anybody replies to this e-mail).  As long as it's a legitimate-LOOKING e-mail address (that your server will recognize) you should be fine.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:ryulite
ID: 17953212
i used my hotmail address but it still doesnt work.. or they cant accept free based address?
0
 
LVL 19

Expert Comment

by:VoteyDisciple
ID: 17953224
It's entirely up to how the SMTP server you're using is configured.  I've worked with some systems that blindly send on any address, and others that only accept mail from addresses on that system.  As I said, your best bet is to use an address on that system (i.e. the system that's hosting your SMTP server) that it will recognize as genuine.
0
 

Author Comment

by:ryulite
ID: 17953382
i used my teknon media's web hosting email but i cant get it to send it to my email account.
0
 
LVL 19

Expert Comment

by:VoteyDisciple
ID: 17953399
Looking back through this I've realized you never actually said...

Does the mail() function actually return true?
0
 

Author Comment

by:ryulite
ID: 17953466
ssorry but i am a newbie to php and i don really know how to run through the code with dreamweaver
0
 
LVL 1

Assisted Solution

by:saukstas
saukstas earned 250 total points
ID: 17954003
If you want to check do this:
 $sent = mail(<everything you wrote there>)

if ($sent) {
 echo "sent ok";
} else {
 echo "sent failed"
}

your php configuration may not allow you to send emails because of missing SMTP configuration. open your php.ini file and look there for configuration value named smtp. you should write there your ISP's SMTP server's address.

Good luck ;)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now