How can I create links inside an email content? can you send me a code for that?

Recommended Answers

All 6 Replies

do you mean as in sending an email with php with a link in the email?

do you mean as in sending an email with php with a link in the email?

exactly, such as the person who got the email would want to give a feedback and he would click the link feedback and a new PHP page would open..

are you sending an html email or a text email?

are you sending an html email or a text email?

I am trying to write the code of sending an email with PHP, and inside the body of the mail I want to create a link..Please if you can help me..

Try this:

This code is for an HTML Email

<?php
$our_email = "youremail@something.com";
$to = "someone@something.com";
$from = $our_email;
$subject = "yoursubject";
$message = <<<EOF
<html>
<body>
<a href="http://www.yourlink.com">Click Here!!!</a>
</body>
</html>
EOF;
$headers  = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
$mail = mail($to, $subject, $message, $headers);
}
if ($mail) {
echo "Message sent successfully";
}
else {
echo "Message didn't send";
}
?>

This code is for a txt email

<?php
$our_email = "youremail@something.com";
$to = "someone@something.com";
$from = $our_email;
$subject = "yoursubject";
$message = "www.somelink.com";
$mail = mail($to, $subject, $message, "From: $our_email");
if ($mail) {
echo "Mail Sent";
}
else {
echo "Error - Mail Not Sent";
}
?>

Can I use html to create a hyperlinked url in the body of an email?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.