wisemonk Posted December 19, 2014 Share Posted December 19, 2014 I have this code I have been trying ot use but it doesnt sent an email to my account when someone enters there email address into it and hots the submit button this is the php side of it <?php if ( isset( $_POST['newsletter_submit'] ) ) { // Initialize error array $newsletter_errors = array(); // Check email input field if ( trim( $_POST['newsletter_email'] ) === '' ) $newsletter_errors[] = 'Email address is required'; elseif ( !preg_match( "/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,4}$/i", trim( $_POST['newsletter_email'] ) ) ) $newsletter_errors[] = 'Email address is not valid'; else $newsletter_email = trim( $_POST['newsletter_email'] ); // Send email if no input errors if ( empty( $newsletter_errors ) ) { $email_to = "news@upperhuntercomputers.com"; // Change to your own email address $subject = "Newsletter Subscription"; $body = "Subscriber details: " . $newsletter_email . "\r\n"; $headers = "Newsletter Subscription <" . $email_to . ">\r\nReply-To: " . $newsletter_email . "\r\n"; mail( $email_to, $subject, $body, $headers ); echo 'Thank you for subscribing!'; } else { echo 'Please go back and correct the following errors:<br />'; foreach ( $newsletter_errors as $error ) { echo $error . '<br />'; } } } ?> and this is the html side of it <!-- Newsletter form --> <div class="newsletter"> <form action="subscribe.php" method="post" id="newsletter-form"> <p class="form-field"> <label for="newsletter_email" class="visually-hidden">Your email address</label> <i class="icon ion-paper-airplane" aria-hidden="true"></i> <input type="text" name="newsletter_email" id="newsletter_email" value="" placeholder="Your email address" /> </p> <p class="form-submit"> <input type="submit" name="newsletter_submit" id="newsletter_submit" value="Get Notified" /> </p> </form> </div> </div> cant figure out why its not working properly Quote Link to comment Share on other sites More sharing options...
Frank_b Posted December 19, 2014 Share Posted December 19, 2014 At first try to use the mail function standalone like this mail('myself@gmail.com','testmail','Hi did you receive this mail?'); Check if you receive the testmail. Don't forget to look into the spam map also. If you do not receive the email then the email() function might be disabled in the php configuration file or the outgoing email server has not been properly set. Please tell us more about the machine where you run you scripts from. (Windows or Linux, home computer or provider ?) Quote Link to comment Share on other sites More sharing options...
wisemonk Posted December 20, 2014 Author Share Posted December 20, 2014 Hey there will try it our I run all my scripts from a provided from godaddy.com i use cpanel so assuming its linux based the server Quote Link to comment Share on other sites More sharing options...
wisemonk Posted December 21, 2014 Author Share Posted December 21, 2014 (edited) hey there it didnt work with the the simple form either dont receive any emails and ther not in the junk folder so not sure whats going on there or where to really look to receive emails from the web site as its all hosted on the same location as well if it helps this is the web site im trying to implement the subscribe form on www.upperhuntercomputers.com Edited December 21, 2014 by wisemonk Quote Link to comment Share on other sites More sharing options...
Solution Frank_b Posted December 21, 2014 Solution Share Posted December 21, 2014 Hi, My advise is to contact the supportdesk of your provider or to use PHPMailer to send your emails by a SMTP server. For example you can use a SMTP server from godaddy.com or one from your internet-connection provider or gmail.com for example. You can find the original PHPMailer repository at https://github.com/PHPMailer/PHPMailer Quote Link to comment Share on other sites More sharing options...
wisemonk Posted December 21, 2014 Author Share Posted December 21, 2014 Hey there I got the problem sorted it was a simple selection in something called mx entry changed from local mail exchanger to remote mail exchanger 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.