pgrevents Posted April 20, 2009 Share Posted April 20, 2009 I am having trouble with php I am new to the whole web design thing and I am having issues with my companys site www.pgrevents.co.uk specificly the php mail for users to activate their account. the script below <? $email = $_POST['email']; $activation = $_POST['activation']; $fname = $_POST['fname']; // email settings $to = ".$email."; $subject = "PGR EVENTS ACTIVATION EMAIL"; $headers = "From: [email protected]\r\n"; $headers .= "MIME-Version: 1.0\r\n" . "Content-Type: text/html; charset=\"iso-8859-1\"\r\n" . "Content-Transfer-Encoding: 7bit\r\n"; $message = include('message.php'); mail($to, $subject, $message, $headers); header ('Location:http://www.pgrevents.co.uk/?display=registration&type=complete'); ?> any help would be greatly appreciated. many thanks Link to comment https://forums.phpfreaks.com/topic/154888-php-mail-confusion/ Share on other sites More sharing options...
premiso Posted April 20, 2009 Share Posted April 20, 2009 So what issue are you having? You failed to mention that bit. Link to comment https://forums.phpfreaks.com/topic/154888-php-mail-confusion/#findComment-814671 Share on other sites More sharing options...
soak Posted April 20, 2009 Share Posted April 20, 2009 You haven't told us what the problem is but I can see one straight off. You can't set a variable ($message in this case) to the value of an include. If message.php contains php code then you'll need to ob_start() before it and ob_get_contents() / ob_flush() after it. If message is just HTML then you can use file_get_contents() EDIT: For some reason you appear to be adding full stops to either side of the $to address as well. Link to comment https://forums.phpfreaks.com/topic/154888-php-mail-confusion/#findComment-814672 Share on other sites More sharing options...
pgrevents Posted April 20, 2009 Author Share Posted April 20, 2009 lol i dont quite know. the file will execute with no errors but no mails going anywhere i know the post vars are working Link to comment https://forums.phpfreaks.com/topic/154888-php-mail-confusion/#findComment-814676 Share on other sites More sharing options...
soak Posted April 20, 2009 Share Posted April 20, 2009 Rather than sending the mail try echoing all the variables in the mail functioon to the screen so that you can check that they look correct. That would have made the "[email protected]." obvious. Link to comment https://forums.phpfreaks.com/topic/154888-php-mail-confusion/#findComment-814677 Share on other sites More sharing options...
premiso Posted April 20, 2009 Share Posted April 20, 2009 $to = ".$email.";// syntax error // should be $to = $email; As far as why it is not sending emails, this can be because of spam filters. I know Yahoo, Hotmail and GMail have some intense filters and sometimes if the domain name does not have a registered mail server to that ip they will not deliver the email. This may very well be out of your control, and I do not know how to fix the issue of the mail server being if it is indeed the issue. Link to comment https://forums.phpfreaks.com/topic/154888-php-mail-confusion/#findComment-814683 Share on other sites More sharing options...
alphanumetrix Posted April 20, 2009 Share Posted April 20, 2009 Aside from the e-mails likely being spam, it may not be sending e-mails because your server isn't allowing it. Many people can't use php's mail() function by itself. They have to use php's standard smtp class with it, as some servers require it. Link to comment https://forums.phpfreaks.com/topic/154888-php-mail-confusion/#findComment-814775 Share on other sites More sharing options...
pgrevents Posted April 21, 2009 Author Share Posted April 21, 2009 hi and thanks for your help. I have edited the script it and i have echoed the form and there are no emails it says the emails are getting sent. I have contacted my isp and they are sure it is a script problem here is my edited code can you please have a look and see if i have made any mistakes. <? $email = $_GET['email']; $activation = $_GET['activation']; $fname = $_GET['fname']; /* subject */ $subject = "PGR Events Activation Code"; /* message */ $message .= " <p align=\"center\"><img src=\"http://www.pgrevents.co.uk/images/pgrlogo.png\" alt=\"PGR EVENTS\" width=\"395\" height=\"196\" /></p> <p>Thank you ".$fname.",</p> <p>You are now registered with PGR Events before you have access to this site you must first confirm your email address. You can do this by clicking the link below or copying and pasting the link into your browser.</p> <p> </p> <br /><p>CLICK HERE TO CONFIRM YOUR EMAIL ADDRESS</p> <p> </p> <p>if the above link does not work copy and paste the below link</p> <p>http://www.pgrevents.co.uk/?display=activate&code=".$activation ."</p> <p> </p> <p>Thank you for your interest in PGR Events</p> <p> </p> <hr /> <p>**This is an Automatic Email** The information in this email and attachments is confidential and intended for the sole use of the addressee(s). Access, copying, disclosure or re-use, in any way, of the information contained in this email and attachments by anyone other than the addressee(s) is unauthorized. If you have received this email in error, please return it to the sender and highlight the error.<br /> <br /> We accept no legal liability for the content of the message. Any opinions or views presented are solely the responsibility of the author and do not necessarily represent those of PGR Events \n"; $headers .= "From: [email protected], PGR EVENTS \n"; $headers .= "To-Sender: \n"; $headers .= "X-Mailer: PHP\n"; $headers .= "X-Priority: 1\n"; $headers .= "Return-Path: [email protected] \n"; $headers .= "Content-Type: text/html; charset=iso-8859-1\n"; mail($email, $subject, $message, $headers); echo $message ?> Link to comment https://forums.phpfreaks.com/topic/154888-php-mail-confusion/#findComment-815513 Share on other sites More sharing options...
pgrevents Posted April 22, 2009 Author Share Posted April 22, 2009 I got a response from my hosting provider that was better than other ones I have recieved. It is now stating that I need to use the -f command. I have no clue of what this is and I got given an example but dont know how to work it into my scrip can someone please oblige me with a fix? the example i got from my hsp is, <? $from = "thefromemailaddress@domain"; mail("recipient@", "Test mail from PHP mail","This is a test PHP Email","From: $from", "-f$from" ); print "Mail sent"; ?> I kind of understand how i might put it in but as I am sending a html email i need to set the from to a header adding in the charset etc and the from email address including the -f command. Many thanks for looking Link to comment https://forums.phpfreaks.com/topic/154888-php-mail-confusion/#findComment-816239 Share on other sites More sharing options...
pgrevents Posted April 22, 2009 Author Share Posted April 22, 2009 what i have came up with is <?php $activation = $_GET['activation']; $fname = $_GET['fname']; $from = "[email protected]"; $Name = "PGR Events"; //senders name $email = "[email protected]"; //senders e-mail adress $recipient = $_GET['email']; //recipient $mail_body = " <p align=\"center\"><img src=\"http://www.pgrevents.co.uk/images/pgrlogo.png\" alt=\"PGR EVENTS\" width=\"395\" height=\"196\" /></p> <p>Thank you ".$fname.",</p> <p>You are now registered with PGR Events before you have access to this site you must first confirm your email address. You can do this by clicking the link below or copying and pasting the link into your browser.</p> <p> </p> <br /><p><a href=\"http://www.pgrevents.co.uk/?display=activate&code=".$activation ."\">CLICK HERE TO CONFIRM YOUR EMAIL ADDRESS</a></p> <p> </p> <p>if the above link does not work copy and paste the below link</p> <p>http://www.pgrevents.co.uk/?display=activate&code=".$activation ."</p> <p> </p> <p>Thank you for your interest in PGR Events</p> <p> </p> <hr /> <p>**This is an Automatic Email** The information in this email and attachments is confidential and intended for the sole use of the addressee(s). Access, copying, disclosure or re-use, in any way, of the information contained in this email and attachments by anyone other than the addressee(s) is unauthorized. If you have received this email in error, please return it to the sender and highlight the error.<br /> <br /> We accept no legal liability for the content of the message. Any opinions or views presented are solely the responsibility of the author and do not necessarily represent those of PGR Events \n "; //mail body $subject = "Email Verification Code"; //subject $from = "[email protected]"; $header = "nContent-Type: text/html; charset=iso-8859-1\n"; //optional headerfields mail($recipient, $subject, $mail_body, $header, "From: PGR Events", "-f$from"); //mail command header('Location:http://www.pgrevents.co.uk/?display=registration&type=complete'); ?> Could someone please have a look. If it does appear to be correct then it gives me more ammo to go back to my hsp with thanks again Link to comment https://forums.phpfreaks.com/topic/154888-php-mail-confusion/#findComment-816263 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.