Jump to content

Recommended Posts

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: info@pgrevents.co.uk\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

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

$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

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: info@pgrevents.co.uk, PGR EVENTS \n";
$headers .= "To-Sender: \n";
$headers .= "X-Mailer: PHP\n"; 
$headers .= "X-Priority: 1\n"; 
$headers .= "Return-Path: info@pgrevents.co.uk \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

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

what i have came up with is

<?php
$activation = $_GET['activation'];
$fname = $_GET['fname'];
$from = "info@pgrevents.co.uk";
$Name = "PGR Events"; //senders name
$email = "info@pgrevents.co.uk"; //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 = "info@pgrevents.co.uk";
$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

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.