How to include a php variable as a link in a php mail() function?

I’m using the mail() function to send an email activation link to any registered user. This is the message:
`$message = "

<html lang='en'>
	<body>
		<h1 style='text-align: center; color: blue;'>You're about to become a new member of Connection!</h1>
		<a href='$link' style='text-decoration: none; font-size: 2em; font-weight: bold; color: #3523FA;'>
			<div style='width: 40%; height: 20%; border: 3px solid #4057ED; background-color: #40E2ED; text-align: center; margin: auto;'>
				<p>Click here to activate your account!</p>
			</div>
		</a>

";However, the link is equal to nothing. I've usedecho $link;to make sure it's right, and$link` is equal to what I wanted it to equal. How do I include this variable in my PHP message?

have you checked echo $message to see what that’s set to?

I have many times, and the href always equals to an empty value.

So there’s something wrong with the way you are assigning the value to $message or something setting $link to blank in between where you were checking it and the assignment to $message

1 Like

Oh hey! You were actually right! $link wasn’t a global variable, since it was within a function. Thanks for this advice:

So there’s something wrong with the way you are assigning the value to $message or something setting $link to blank in between where you were checking it and the assignment to $message

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.