This question already has answers here:
How to send HTML/CSS emails?
(4 answers)
Closed 8 years ago.
I need to send a verification email, its working fine. But i don want to show the "link" in the email i just need to show some text like "click here to verify"
{
$verify_email="
Hello,
Thank you for signup.
For verify e-mail go to this http://".$site_url."/verify.php?user=%s&key=%s;
Or enter your verify code on verification page. Code is: %s
Thanks you.
";
}
This sends a email like the below
Hello,
Thank you for signup.
For verify e-mail go to this http://testsite.com/verify.php?user=username&key=de94569d40077060f5f5eb;
But i need this to be
Hello,
Thank you for signup.
For verify e-mail click here
Please help me
{
$verify_email="
Hello,
Thank you for signup.
For verify e-mail <a href='http://".$site_url."/verify.php?user=%s&key=%s> go to this </a>
Or enter your verify code on verification page. Code is: %s
Thanks you.
";
}
This is regular HTML markup. Use the anchor tag and enclose your URL in the href attribute.
Use this code
<?php
$to = 'your recipients';
$subject = 'Your subject';
$message = 'Your html code';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to, $subject, $message, $headers);
?>
Try this
$verify_email='
Hello,
Thank you for signup.
For verify e-mail go to this Click here
Or enter your verify code on verification page. Code is: %s Thanks you.';
Related
This question already has answers here:
Redirecting to previous page after login?
(18 answers)
Closed 2 years ago.
hi how can i send back to previous page in php
<?php
$to = "email";
$subject = "mailed from";
$txt = $_POST['first-name']." ".$_POST['last-name']." sends message from. persons number is: ".$_POST['phone']." message is: ".$_POST['message'];
$headers = "From: ".$_POST['email'];
mail($to,$subject,$txt,$headers);
?>
Try using php header function.
Example would be in PHP
header("Location: $_SERVER['HTTP_REFERER']");
Where $_SERVER['HTTP_REFERER'] by PHP.net is
The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.
<?php
$to = "email";
$subject = "mailed from";
$txt = $_POST['first-name']." ".$_POST['last-name']." sends message from.
persons number is: ".$_POST['phone']." message is:
".$_POST['message'];
$headers = "From: ".$_POST['email'];
mail($to,$subject,$txt,$headers);
// Redirect after mail
header("Location: $_SERVER['HTTP_REFERER']");
?>
Use can use this for redirections -
header("Location: pagename.php");
Replace pagename.php with your page.
Place it below mailing code so that it will redirect after the mail gets sent.
This question already has answers here:
Php mail: how to send html?
(5 answers)
Closed 5 years ago.
I 'm using a single form to allow my guests subscribe on my upcoming website.
My problem is that i really dont know how to make this email has some css style. I tried inline css but nothing happens. The email i receive just display the code of styling and it doesnt transform it into html!
The code i use is this:
<?php
if(isset($_REQUEST["isvalid"])){
$youremail = "info#mywebsite.com;
$usersemail = $_POST["usersemail"];
$mailsubject = "You have a new subscriber";
$message ="
<div style='width:300px;padding:20px;margin:0 auto;background:#84C318;color:#ffffff;border-radius:3px;'>
Email Address: $usersemail
</div>
";
$headers = 'From:' . $usersemail . "\r\n";
mail($youremail, $mailsubject, $message, $headers);
echo "success";
} else {
echo "failed";
}
?>
I am not sure but i think i can add inline css style inside a variable. i also tried to move the inline style outside the variable but i got the same result.
Need some help here..
You need to specify that your email is a html email by setting the Content-type header to "text/html".
More information here: https://css-tricks.com/sending-nice-html-email-with-php/
Please bear with me as I'm still very new to this. I'm simply trying to ensure the email message body below has linebreaks where I put <br/>. However when I run the script the message body displays exactly as it is in the script even though it works perfectly in the editor I used to compose this email at Stackoverflow.
I realize its something very small and subtle. /n also didnt seem to work. Thanks for your help! I'm not sure i understand how to use nl2br in my particular context. Again thanks for your patience and help.
$subject=" You're exclusive guide is only a click away!";
$message="Thanks for subscribing .$name! <br/> Click below to confirm your email and email and access your guide <br/> http://acmecorp.net/guide <br/> Acmecorp.net <br />Phone: 800-123-4468";
$headers = 'From:AcmeCorp<info#acmecorp.net>';
mail( $email, $subject, $message,$headers );`
Substitute <br/> with "\n":
$subject=" You're exclusive guide is only a click away!";
$message="Thanks for subscribing .$name! \n Click below to confirm your email and email and access your guide \n http://acmecorp.net/guide \n Acmecorp.net \nPhone: 800-123-4468";
$headers = 'From:AcmeCorp<info#acmecorp.net>';
mail( $email, $subject, $message,$headers );`
You want to use HTML tags in a mail obviously. So, you have to send your mail in HTML, by adding a content type revelant in the headers.
Just before your mail() call, add $headers .= "Content-type: text/html\r\n"; to have something like this:
$subject = " You're exclusive guide is only a click away!";
$message = "Thanks for subscribing .$name! <br/> Click below to confirm your email and email and access your guide <br/> http://acmecorp.net/guide <br/> Acmecorp.net <br />Phone: 800-123-4468";
$headers = 'From:AcmeCorp<info#acmecorp.net>';
$headers .= "Content-type: text/html\r\n";
mail($email, $subject, $message, $headers);
A user fills out a form which is sent to my email via the variables their data is read into.
I want to have headers above each users entry, and have these appear bold in the email.
The email should read:
OCCUPATION:
Data the user entered.
I have tried
$Occupationheader = "<strong>"."OCCUPATION"."</strong>"."\n\n" ;
and
$Occupationheader = "<strong>OCCUPATION:<strong>\n\n";
The data is sent to the email, as follows: (this works, but want to format the headings in bold).
mail( "myemailaddress", "subjectmatter",
$Occupationheader.$Occupation);
Any ideas?
Thanks guys.
$mailContent = "<html>
<body>
<strong>HEADER</strong>
<br/>message
</body>
</html>";
NOTE: This is provided as an additional answer.
Without seeing full source code, am providing my (additional) answer below.
The following, need to be present in your code, in order to send out Emails in HTML format:
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
As per the PHP manual on the subject: http://php.net/manual/en/function.mail.php
The following PHP code works perfectly, but it is not doing line breaks for some reason.
PHP:
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=utf-8\n";
$headers .= "From: '".$title."' <".$store_email."> \n";
$subject = "New Payment Received";
//MESSAGE
$message = "New payment was successfully recieved through paypal payment terminal:";
$message .= "\r\n\nFrom ".$paypal->pp_data['payer_email'];
$message .= "\r\nPaid: ".$paypal->pp_data['payment_gross']." ".$paypal->pp_data['mc_currency'];
$message .= "\r\nDate: ".date('d/m/Y');
$message .= "\r\nTime: ".date('g:i A');
mail($admin_email,$subject,$message,$headers);
Any wonder what's wrong? Thanks in advance.
You're sending HTML e-mail. Line breaks have no meaning in HTML, you'll need <br /> tags.
The direct answer ceejayoz gives is correct and to the point in that the html element <br> is needed because it is a html email.
The bigger issue is that not all email is readable in html (example: user doesn't allow html emails). Anyone sending email should send it in 2 parts. One being a html formatted message and the other "alternative" in plain text. In that way the recipient will be able to read the email regardless of email reader.
The \r\n line break works in plain text alternative part and in html<br> or other elements as needed to format.
Doing this will avoid the next question. Recipients are complaining my emails are blank.