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 = "xxyyzz@yahoo.com";
		$headers = "From: $from";
		mail($to,$subject,$message,$headers);

 

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

 

Link to comment
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 something@yourdomain.com 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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.