Jump to content

mail() not sending to Gmail, Yahoo etc.


Canadian

Recommended Posts

I'm using a simple form to grab an email address and send the person who signs up and automatic response.  It was working for a while and now it's not.  Not sure what happened.  My hosting company told me to look into my headers.  Can anyone help?  Here is my code.

 

Thanks,

 

<?php

			/* Set e-mail recipient */
			$subject = "Sign Up";
			$headers = "From: admin@xxx.com" . "\r\n" . "CC: admin@xxx.com";

			/* Check all form inputs using check_input function */
			$sign_up_email_address = check_input($_POST['sign_up_email_address'], "Please enter your email address.");

			/* If e-mail is not valid show error message */
			if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $sign_up_email_address)) {

				show_error("E-mail address not valid");

			}

			/* Let's prepare the message for the e-mail */
			$response_message = "Sample Message";

			/* Send the message using mail() function */
			mail($sign_up_email_address, $subject, $response_message, $headers);

			/* Functions we used */
			function check_input($data, $problem='') {

				$data = trim($data);
				$data = stripslashes($data);
				$data = htmlspecialchars($data);

				if ($problem && strlen($data) == 0) {

					show_error($problem);
				}

				return $data;

			}

			function show_error($myError) {
			?>

			<?php echo $myError; ?>

 

Thank you,

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.