troubleshooting Question

php mail fails on subsequent mail sending

Avatar of rinfo
rinfo asked on
PHPScripting Languages
15 Comments1 Solution438 ViewsLast Modified:
I have used following codes for sending mail to user and admin.
First code is for users and it works ok.
Only problem is it sometime lands on junk/spam.
However when it sends mail to admin after sending mail to user - there is no error notified.
But admin is not recieving mail.
I have checked message body is properly populated.
Email provided is valid and working.
Can someone please tell me where i am wrong and what measure i have to take to prevent user mail going to junk.
Thanks
$email_from = 'webadminmailid@hotmail.com';
            $email_message ='
            <html>
            <body>
             message body here
            </body>
            </html>
           
            


			$headers  = "MIME-Version: 1.0" .  "\r\n";
                    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";	
			$headers .= ' From: '.'mymailid@hotmail.com'."\r\n" .
                           'Reply-To: '.$email_from.'\r\n' .
                           'X-Mailer: PHP/' . 'phpversion()';
			@mail($email,'Thank-you', $email_message, $headers);

			
			
			

			$headers1 = '';
			$emailto  = "adminmailid@gmail.com";
	        $email_from1 = $_POST['email'];
	        $email_message1 = "A new user having following details has registered on ".date("Y-m-d")." at ".date("H:i")."\n\n";
	        foreach($_POST as $field_name => $field_value) {
	        $email_message1.= $field_name.": ".$field_value."\n\n";
	        }
			$headers1 = 'MIME-Version: 1.0' . "\r\n";
			$headers1 .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
	        $headers1 .= 'From: '.$email_from1."\r\n" .
                           'Reply-To: '.$email_from1."\r\n" .
                           'X-Mailer: PHP/' . phpversion();
                // send the email
			
            mail($emailto,"New Registration", $email_message1, $headers1) ;
            if($mail->ErrorInfo) { die($mail->ErrorInfo) ; }   
				
		header("location: register-success.php");
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 15 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros