garydt Posted June 24, 2007 Share Posted June 24, 2007 I've got a mail script, i'm not getting errors but i'm not getting emails either. $username = $row_Recordset4['usernm']; $from = 'test@uk.com'; $to = 'gary@garyt.co.uk'; $body = "test"; $headers = "From: info@example.com \r\n"; $headers.= "Content-Type: text/html; charset=ISO-8859-1 "; $headers .= "MIME-Version: 1.0 "; mail($to, "An HTML Message", $body, $headers); php.ini file- [mail function] ; For Win32 only. ;SMTP = smtp.tiscali.co.uk ;smtp_port = 25 ; For Win32 only. sendmail_from = me@localhost.com sendmail_path = C:\Program Files\xampp\sendmail pop3_server= pop.tiscali.co.uk pop3_username= garydt88 pop3_password= garytanner Quote Link to comment Share on other sites More sharing options...
bonaparte Posted June 24, 2007 Share Posted June 24, 2007 if (mail()) { // mail was sent } else { // mail was not sent } Try using a reliable method, ie, authenticating to the SMTP server and then sending the mail. Quote Link to comment Share on other sites More sharing options...
chigley Posted June 24, 2007 Share Posted June 24, 2007 mail() does not return true/false depending on whether the mail was sent. Quote Link to comment Share on other sites More sharing options...
bonaparte Posted June 24, 2007 Share Posted June 24, 2007 "Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise. "It is important to note that just because the mail was accepted for delivery, it does NOT mean the mail will actually reach the intended destination. " From http://in2.php.net/manual/en/function.mail.php Quote Link to comment Share on other sites More sharing options...
chigley Posted June 24, 2007 Share Posted June 24, 2007 It's a "faulty" function if you like, because it's returns aren't accurate at all. Quote Link to comment Share on other sites More sharing options...
bonaparte Posted June 24, 2007 Share Posted June 24, 2007 That's exactly is what the manual says, although it is not faulty. I don't know how this works on Windoze. In my experience I have learned that it is safe and reliable if you use a PHP script that connects and authenticates to the SMTP server to send mails. Quote Link to comment Share on other sites More sharing options...
garydt Posted June 24, 2007 Author Share Posted June 24, 2007 Thanks alot. Can you explain how to connect and authenticate to the SMTP server. I'm trying to send emails to myself, not getting any. Quote Link to comment Share on other sites More sharing options...
bonaparte Posted June 24, 2007 Share Posted June 24, 2007 I use Zend framework for most of my web sites. You may want to have a look at Zend_Mail http://framework.zend.com/manual/en/zend.mail.html . There are many useful SMTP mail scripts in phpclasses.org. Quote Link to comment Share on other sites More sharing options...
garydt Posted June 25, 2007 Author Share Posted June 25, 2007 I'm still having trouble. [cod]$from = 'test@uk.com'; $to = "gary@garyt.co.uk"; $body = "test"; $headers = "From: info@example.com \r\n"; $headers.= "Content-Type: text/html; charset=ISO-8859-1 "; $headers .= "MIME-Version: 1.0 "; if (mail($to, "An HTML Message", $body, $headers)){ //if sent tell them. echo"Your email was sent to $to"; }else{ //if not sent tell them. echo"Sorry no email sent please try agin."; } When i try it i get the message saying it was sent but i still get no email. I've downloaded zend but i don't know how to use it, it has no instructions. I thought sending emails in php was supposed to be easy. Please help. Quote Link to comment Share on other sites More sharing options...
redarrow Posted June 25, 2007 Share Posted June 25, 2007 try this ok. <?php // To who ever. $to = 'xxxxxxxx@xxxxxxx.xxxxx'; //from you the sender. $from='xxxxxxxx@xxxxxx.xxxx'; //Subject line what ever. $subject = 'hi mate it me aging how\'s you!'; $mess='<html><head><title>my good message for you mate</title> <body> <h1> redarrow look at this good web site unreel <p></p> <a href="http://www.google.com">Go there Know it unreel mate</a></h1><p></p> </body></html>'; $message = $mess; $headers = "From: $from\r\n" . 'X-Mailer: PHP/' . phpversion() . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/html; charset=utf-8\r\n" . "Content-Transfer-Encoding: 8bit\r\n\r\n"; // send if correct. if(mail($to, $subject, $message, $headers)){ //if sent tell them. echo"Your email was sent to $to"; }else{ //if not sent tell them. echo"Sorry no email sent please try agin."; } ?> Quote Link to comment Share on other sites More sharing options...
garydt Posted June 25, 2007 Author Share Posted June 25, 2007 Thanks. I tried that, I still got no email. What now? Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted June 25, 2007 Share Posted June 25, 2007 have you checked you junk mail? it may be getting filtered out. Quote Link to comment Share on other sites More sharing options...
gtk Posted June 25, 2007 Share Posted June 25, 2007 If you use Zigmoyd Mailer It will Work and send the mails. If it fails it will display you why It failed if there is a Problem in SMTP server It will also Display you that and Its simpler than that Of mail(). And generally All mails Goes To INBOX NOT in Spam or Junk. $mail = new mail("to@localhost", "Subject", "Mail Body"); if($mail->send()) { echo "Mail Sent Successfully\n"; } else { echo "Sorry Mail Sending Failed\n"; print_r($mail->error);//Print The Errors } See the class at http://zigmoyd.sourceforge.net/man/mail.php#mail Installation and Instruction at http://zigmoyd.sourceforge.net/man/index.php Edit the setup_mail.php (in teh mail Folder) accordingly.In real life Situation you may not be able to edit php.ini file. Then also you can use it. It will also Sho you how does a mail Goes Quote Link to comment Share on other sites More sharing options...
gtk Posted June 25, 2007 Share Posted June 25, 2007 Hope teh Above Works. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.