Jump to content

problem with sending email


optiplex

Recommended Posts

ive tried this coding.. but the email didnt send at all... the code

                        $to = "$t_email";
		$subject = "Request account";
		$message = "good morning. your application bla bla bla\n\n\nregards, admin";
		$from = "[email protected]";
		$headers = "From: $from";
		mail($to,$subject,$message,$headers);

 

is it because of the hosting mail server or anything else? tq

 

Link to comment
https://forums.phpfreaks.com/topic/168290-problem-with-sending-email/
Share on other sites

My guess is your hosting service doesn't allow emails to be sent from external domains. If you change the $from to [email protected] does it work? Try removing the $headers part all together too.

 

Long story short, your code is fine. Your hosting service must be blocking it for some reason. Call your hosting service and ask them what you need to do.

Well, I just tested your code and it works fine. The only other thing it could be, is $t_email not being set correctly. Are you sure that value is good?

 

Next step is to call your hosting service. It could be that mail is not configured correctly at all on the system and they need to change something at the system level. Either way, there is no other changes you can make from a coding level to make this work.

The From: address must be a valid mail box at the sending mail server. You should put any entered email address (after validating it) into the Reply-to: address, not the From: address.

 

Most sending mail servers won't accept an email from a php script unless either the From: or the To: address is hosted at the sending mail server and receiving mail servers are not going to accept an email that has a domain in the From: address that does not match the sending mail server. Would you trust a letter that has a sender's address from someone you don't personally know (from a US address for example) that is completely different from the postmark of the post office where the letter was sent from (a postmark from China for example)?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.