Jump to content

Mail


duncan_cowan

Recommended Posts

Please could you tell me what is wrong with this script:

<?phprequire("protected/db_connect.php");$rand = mysql_query("SELECT act_num FROM unactivated_users WHERE username=".$_POST['uname']);// Some data for the message$mailTo = $_POST['email'];$mailFrom = "activation@wasper_rocker.co.uk";$mailFromName = "World War 6";$mailSubject = "Account Activation";$mailMessage = "<html><body>".$_POST['uname']."<br />Thank you for registering an account with World War 6.<br /><br />To activate your account please click this address or copy it to your browser:<br /><a href='http:\\www.wasper-rocker.co.uk/activate.php?act_num=$random'title='http:\\www.wasper-rocker.co.uk/activate.php?act_num=$random'></a>.<br /><br />If you have any problems activating your account please reply to <a href='mailto:activation@wasper-rocker.co.uk?subject=Activation Problems'>this email address</a>.</body></html>";$headers  = 'MIME-Version: 1.0 . \r\n';$headers .= 'Content-type: text/html; charset=iso-8859-1 . \r\n';$headers .= 'From: $mailFromName <$mailFrom> . \r\n';// Send mailmail($mailTo, $mailSubject, $mailMessage, $headers);?>

??? thanks

Link to comment
Share on other sites

I don't know if it's just the way it is posted on this forum, but it looks like your $mailMessage string spans multiple lines. I've seen many people here post about this, so you might try changing it to something like this:

$mailMessage  = "<html><body>".$_POST['uname']$mailMessage .= <<<HERE<br />Thank you for registering an account with World War 6.<br /><br />To activate your account please click this address or copy it to your browser:<br /><a href='http:\\www.wasper-rocker.co.uk/activate.php?act_num=$random'title='http:\\www.wasper-rocker.co.uk/activate.php?act_num=$random'></a>.<br /><br />If you have any problems activating your account please reply to <a href='mailto:activation@wasper-rocker.co.uk?subject=Activation Problems'>this email address</a>.</body></html>HERE;

Check out the manual and scroll down to the Heredoc section.If this doesn't fix it, perhaps you can let us know what error message(s) you are getting.

Link to comment
Share on other sites

When I use your idea the error message is :

Parse error: syntax error, unexpected T_VARIABLE in /home/i04wasp/public_html/regmail.php on line 13

but when i use my first script the e-mail is sent fine but the message shows the html tags.What can i do to make the message be displayed as html?

Link to comment
Share on other sites

What can i do to make the message be displayed as html?
I think I saw someone else post about this recently and I believe the answer was in the headers that get sent in the email. This link may help: http://www.sitepoint.com/article/advanced-email-php/3EDIT: I found the post - http://w3schools.invisionzone.com/index.ph...94&hl=email
Link to comment
Share on other sites

in the script there is a line with the following code:

$rand = mysql_query("SELECT act_num FROM unactivated_users WHERE username = ".$_POST['uname']."") or die("Find act_num Error");

i have managed to get the email to be sent as html but this line isnt working for some reason please could some one help??Thanks in advance!! :)

Link to comment
Share on other sites

I believe you may be missing quote marks around the value of the username. The final SQL query should look something like:

SELECT act_num FROM unactivated_users WHERE username = 'duncan'

Try changing your code to:

$rand = mysql_query("SELECT act_num FROM unactivated_users WHERE username = '".$_POST['uname']."'") or die("Find act_num Error");

Link to comment
Share on other sites

Heres your issue:

<a href='http:\\www.wasper-rocker.co.uk/activate.php?act_num=$random'title='http:\\www.wasper-rocker.co.uk/activate.php?act_num=$random'></a>.

It doesnt recognize the variables, at least it doesnt expect them. Try this:

<a href='http:\\www.wasper-rocker.co.uk/activate.php?act_num={$random}'title='http:\\www.wasper-rocker.co.uk/activate.php?act_num={$random}'></a>.

Then it will work. Also, to display HTML in an email you will need to set the correct mime. I forget what exactly it is but its been posted on here about 10 bajillion times lol.

Link to comment
Share on other sites

<a href='http:\\www.wasper-rocker.co.uk/activate.php?act_num={$random}'title='http:\\www.wasper-rocker.co.uk/activate.php?act_num={$random}'></a>.

i have tried this but when i get the email the link doesnt show up!?
Link to comment
Share on other sites

that's because there's nothing in the email. try this:

<a href='http:\\www.wasper-rocker.co.uk/activate.php?act_num={$random}'>http:\\www.wasper-rocker.co.uk/activate.php?act_num={$random}</a>.

notice that instead of putting the url in title, I put it inbetween the tags.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...