Jump to content

PHP mail()


ayok

Recommended Posts

Hi,

 

I've got a problem with php mail function. It works actually fine with normal e-mails, but it's not sent when the e-mail address is an alias.

 

This is what i mean. The client has for example www.client.com and the e-mail address should be like info@client.com. HOwever he created this e-mail address at gmail. I don't really understand how, but these alias (like admin@client.com, info@client.com, etc) were made with gmail account. So anything which is sent to info@client.com will be redirected to his gmail account.

 

But then, the php mail() cannot send to these addresses.

 

Has anyone had this experience? What is the solution?

Thanks in advanced,

ayok

Link to comment
Share on other sites

have you tried sending email to these addresses outside of php ... like in a normal email program to see if they are set up properly.  It sounds like a DNS error where it is not sure where to forward the emails to.

 

I suggest you send a test email to see if you receive that first.

Link to comment
Share on other sites

It's more likely that your code is putting an address into the From: mail header that is not an email address hosted at your sending mail server. For example, you are putting the email address that someone entered in a form into the From: address. Could you post the code you are using.

Link to comment
Share on other sites

Here is my code

$query_adminsite = "SELECT * FROM owner";
	$adminsite = mysql_query($query_adminsite) or die(mysql_error());
	$data = mysql_fetch_array($adminsite);
                $Name = $data['name']; //senders name from database (owner)
	$email = $_POST['email']; //senders e-mail adress
	$recipient = $data['email']; //recipient e-mail from database (owner)

	$subject = "Sent from ".$Name; //subject

	$header = "From: ".$email . "\r\n"; //optional headerfields 

                //mail body
	$content .= "Name: " . $_POST['name'] . "\n";
	$content .= "Company: " . $_POST['company'] . "\n";
	$content .= "Address: " . $_POST['address'] . " " .$_POST['number']."\n";
	$content .= "Postcode/City: " . $_POST['pcode'] . " " .$_POST['city']."\n";
	$content .= "Phone number: " . $_POST['phone'] . "\n";
	$content .= "E-mail:" . $_POST['email'] . "\n";
	$content .= "Comments: " . $_POST['remarks'] . "\n\n";

	if(mail($recipient, $subject, $content, $header)) {
		echo '<p>Sent!</p>';
		$show = false;
	}
	else {
		echo '<p>Not sent</p>';
		$show = false;
	}

Link to comment
Share on other sites

Most of the major ISP's check that the email is actually coming from a mail server that is authorized to send an email for the domain in the From: address.

 

You should put the email address from the form into the Reply-to: mail header and put a valid email address at the sending mail server into the From: mail header.

 

Would you trust a letter with a From: address of your bank, but the post mark (where it was actually mailed from) was a different country from where your bank is located?

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.