Email Form first name capital - php

I am using dreamweaver and have a form on my page. I managed to collect details from the user and email them etc but would like it to have the punters name first letter in capital.
$MailSubject = "".((isset($_POST["pename"]))?$_POST["pename"]:"") ." Sent Email From space see Website.";
I have had a look around and have tried adding
ucfirst($foo);
but that didnt work.
can someone please advise me as to how to add the ucfirst to the mail subject variable.
thank you
Seemore

Related

Using Chrome's "Copy email address" on mailto link returns encoded useless text instead of a correct email address

We have a website with restricted access (only for exclusive members) coded in PHP.
On the Contact page we have a bunch of mailto links, for example:
address#domain.com
If a visitor clicks on one of the links, it does the usual stuff (opens a new email in Thunderbird with the To: field correctly filled in).
The problem is when a visitor right-clicks on one of the links, selects "Copy email address" and then pastes it in the To: field or wherever (even in a document), in which case the result would be:
Name%20SURNAME%20%3Caddress#domain.com%3E
instead of
Name SURNAME <address#domain.com>
I've been searching for a solution for hours and already tried rawurlencode(), urlencode() and other possible tricks, with absolutely no effect.
Can some of you please help me?
Here is the PHP code that generates the link:
<?php echo ''.$email.''; ?>
//where $email is a valid email address
//and $name is plain text (usually two words with a space character between)
I believe you're trying to do something that simply cannot be done.
I understand the idea but... it's not a thing.
I found no docs saying that you can put a name and enclose the email address in <>.
https://developer.mozilla.org/.../a#Creating_an_email_link
https://developer.mozilla.org/.../Creating_hyperlinks#E-mail_links
IETF RFC6068
You can of course do:
address#domain.com
I found this : https://stackoverflow.com/a/25854290/3376036.
It seems it's actually not supported but it usually works

PHP MySQL how pass value of variables into email body using placeholders

I am building an emailing template system using PHP. The idea is that the same system can be used to send a variety of automated email, eg when people join a site etc. The contents of each email are held on a MySQL database and I use placeholders to represent dynamic elements such as name, email, etc. The placeholders take the form of two underscores before and after a name: __name__, (NB the stackoverflow markup may convert the underscores to make the placeholder name appear in bold here) and a separate field matches the placeholder to the variable it represents eg:
__name__=[($user['name'])], __email=[($user['email'])]
When I construct the email, the system takes the placeholders and holds them in an associative array:
$placeholders( '__name__' => $user['name'], '__email__' => $user['email'] );
This is exactly how the array appears. I have used explode to strip out the enclosing [( and )] brackets.
I am able to loop through the email content and use Parsedown and preg_replace to swap the placeholders with their corresponding variables, eg:
$body = 'Dear __name__, your email is __email__'
becomes:
$body = 'Dear $user['name'], your email is $user['email']
However, this is exactly how the content appears in the final email that is actually sent. The value of these variables (which I have successfully established previously in an array $user ) do not appear in the final text, eg:
'Dear John, your email is john#smith.com'.
How do I get PHP to replace the variables with their values before the email is sent?
PS I have also tried:
'Dear ' . $user['name'] . 'Your email is ' . $user['email']
(ie with an inverted comma and a period to differentiate the variables from the rest of the text ) but no avail. It appears as:
Dear Mr Mercer,
Thank you for registering your details with mercermania.com.
Please verify your email address now
We now need to verify that the email address you supplied when you registered does indeed belong to you. Please click on the following link:
http://www.mercermania.com/activation/?x=' . $user_info['email'] . '&y=' . $user_info['active'] . '
I have done it before, so know it can be done but for the life of me I cannot remember how!
Any help greatly appreciated.
PS I am using PHP Mail::factory to send the email and an email is actually sent, and is received, so that is not the issue.

php mail html format link remains inactive

I wanted to make a mail function in php to let visitors create and activate a user account. For this I made a mail with a link which refers to the page that activates the account. Now the problem is that some people want to use characters that interfere with the code inside the email. for example: " " and ' '. I tried to escape these characters, but when such character appears, the link becomes inactive. The mail is sent, but the link is unclickable.
This is what the code looks like.
The variables are set in PHP
$New_user->Username = $db->real_escape_string($_POST['un']);
$RawUn = $_POST['un'];
$New_user->Password = $_POST['pw'];
$New_user->Email = $_POST['em'];
$CheckEmail = explode("#", $New_user->Email);
$New_user->Country = $_POST['cn'];
$New_user->City = $_POST['ct'];
//$NEW_USER IS AN OBJECT CREATED TO HOLD ACCOUNT INFORMATION SUCH AS USERNAME AND EMAIL
//$RAWUN IS A VARIABLE TO HAVE AN UNESCAPED VALUE OF THE USERNAME TO INSERT IN THE INPUT FIELD IF SOMETHING WENT WRONG
After checking the values, the mail is sent:
$message = array(
'Hello ' . $New_user->Username . ',<br/>',
'<br/>',
'Welcome to MakeAMemo.<br/>',
'To start working with your account you will have to activate it.<br/>',
'Just click on the link and you are ready to go.<br/>',
'Log in and check if it works. If not, please contact us(E-mail is on the website).<br/>',
'Your password: ' . $New_user->Password . '<br/>',
'<br/>',
'Kind regards,<br/>',
'<br/>',
'Administration');
$header = array(
'From: makeamemoofficial#gmail.com',
'Reply-To: makeamemoofficial#gmail.com',
'Content-type: text/html');
mail($New_user->Email,"MakeAMemo => New account",implode("\r\n", $message),implode("\r\n", $header));
I have made a connection to the datebase, so the escaping using $db->real_escape_string works fine.
The location of the link will be changed when the website is finished.
I checked if the code worked without the str_replace in the href. No succes. Neither I got succes trying to not escape the username.
The tags are invisible in the mail, so it is recognised. The link is not blocked, because it does work when I don't use special characters. When changing the double quotation marks into single quotation marks, you reverse the effect, which means that instead of " ", ' ' don't work.
I do not think the headers have something to do with it, because the link does work when using normal characters.
Any idea what the cause of my problem is?
Every answer is appreciated.
adear11: here is the generated tag:
link
"s avonds is an incorrect dutch word that contains some of the characters that need to be tested.
Rather than using str_replace in your email, you should use urlencode http://php.net/urlencode
This function is specifically for encoding strings for use in urls
As for the link not always working when it is formed properly, would be that the user isn't using HTML email.
Also, while not specific to your problem, this script is crazy insecure. You never ever ever need to use user supplied input ($_POST in your case) without sanitizing the input first. At a minimum, all of those assignments need to be run through htmlspecialchars.
Update
Given the trouble that you are having, I would consider not passing the actual data around in the URL. Rather, I would save the data to the DB and then generate a token to put in the url. If you generate a token with uniqid you won't have any trouble with these special characters because the string will be alphanumeric. Once the user clicks the link, just grab the data associated with the token and proceed as you would if the data was in the URL.

Passing HTML entities through URL

I am trying to pass the Euro symbol i.e "€" and the "#" symbol, but they are not working, the euro symbol is looking like "€" and the "#" symbol is looking like "%40", I am using "urlencode()" function in PHP, but it doesn't seem to work, please let me know what could be wrong.
P.S I am transferring data from GET to another page then sending it in email, in email it is looking like the above.
EDIT: This is page 1:
$temps=urlencode($temps);
header('Location:http://someurl.com/mailx.php?data='.$temps);
This is page 2: Here I am emailing the data.
$mailmsg = $_GET['data'];
Output seen in my email inbox:
Email: name%40gmail.com
Notice that %40 instead of "#"?
You need urldecode(), read more here.
$var = "name%40gmail.com";
echo urldecode($var);
//output name#gmail.com

Problem using comma in from field in headers of php mail

How can i put commas in the 'From:' field of the mail headers??
For example with "From:Javier, My Site" when i read the email sended with any mail client like outlook, in the From only appears Javier#myinternalserverurl.com.
It cuts the from field by the comma... All the things that i found about 'From' field in php mails says that if you put commas automatically is treated like a list of mails.. any suggestion?
Thanks in adevice!
"From: \"Javier, My Site\" <email#domain.com>" should work

Categories