HTML Email - Server Username visible as the sender - php

I have a website where whenever a order is placed, an email is sent to the customer as well as the admin.
Now the emails are sent to both the customer and Admin, but the header where i specify the email for the addresser does not work. When the email arrives the addresser email is displayed as my username used to login to the Server.
I managed to get the addresser email to work only when the email is NOT formatted with HTML.
I used HTML to format the emails and I use 'mail()' function to send it.
eg.
I have the same code for Admin email but with different variables..
$toCustomer = "customerEmail#gmail.com";
$customerSubject = "Order Confirmation";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\b";
$headers .= 'From: automatedMesage#PleaseDoNotReply' . "\r\n";
$customerTxt =" Order has been placed!!";
mail($toCustomer,$customerSubject,$customerTxt,$headers);

Related

adding a hyperlink in a sms email

What I am trying to do is send a registration confirmation sms via email from my website. I have it working now but I want to make sure that people are putting in correct phone numbers and carrier data. When my message sends it will send the word link but its not clickable is there a way to make the link clickable?
Here is my code so far.
<?php
$to = $mobil.$carier;
$subject = 'Registration for'.$school .'Scholarships Page';
$message = "
<html>
<head>
<title>Registration Email</title>
</head>
<body>
<h1>Email Registration Confirmation</h1>
<p>Welcome".$first_name." ". $last_name."
<p>In order to finish your registration for the scholarship site you need a valid
text phone number.
<p>Please Click the link given to confirm your registration.</p>
<a href=\"http://scholarship_domain/scholarships/activate.php?id=".$active_mobil ."\">Link
</a>
<p>If you have problems please contact your counsellor at your school. </p>
</body>
</html>
";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: <scholarships.gnspes.ca>' . "\r\n";
mail($to,$subject,$message,$headers);
?>
What happens now is the message sends but the link is not clickable and only the words "link" show up in the message. I guess I could just make it a link that a person could copy and paste but I am wondering if there is a way to make it a true hyperlink?
Thanks for the help.
When sending an Email or SMS to a phone number the message is automatically changed into html on the phone. I was able to get a clickable link send to myself with the following code but I would suggest making the message that it sends a little bit shorter because this message has to be sent as a picture message. I sent it to myself using just 0000000000#vtevt.com and it worked but the message was too long to show all the info so I sent just the link part and it works.
<?php
$to = $mobil.$carier;
$subject = 'Registration for '.$school .' Scholarships Page';
$message = '
Email Registration Confirmation
Welcome '.$first_name.' '. $last_name.'
In order to finish your registration for the scholarship site you need a valid
text phone number.
Please Click the link given to confirm your registration.
http://scholarship_domain/scholarships/activate.php?id='.$active_mobil .'
If you have problems please contact your counsellor at your school.
';
$message = str_replace("\n.", "\n..", $message);
// Always set content-type when sending HTML email
//$headers = "MIME-Version: 1.0" . "\r\n";
//$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
//$headers .= 'From: <scholarships.gnspes.ca>' . "\r\n";
mail($to,$subject,$message);
?>
Also there is no need to send headers in a text message if that's where your sending it to. And the subject doesn't work in a text. It only shows the email or website that it was send from.

PHP mail shows BCC address in the email

My application sends emails to an Admin and to Customers upon payment is received.
I would like to add a BCC field for a backup email and do not want it to show.
I tried adding it as a BCC field but it is still showing when the email is received. The header reads as follows:
to me, bcc: the BCC e-mail, bcc: second BCC email
My code is as follows:
$to="email#hotmail.com";
$subject= "New order";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: <email#gmail.com>' . "\r\n";
$headers .= "CC:".PHP_EOL;
$headers .= "BCC: email#hotmail.com, email2#hotmail.com".PHP_EOL;
mail($to, $subject, $msg2, $headers);
mail($email, 'Payment Confirmation', $msg2customer, $headers);
I tried removing the CC field, still the same result.
*Note: When the emails are received by a #hotmail.com account the BCC are hidden, but when received by a #Gmail.com account the BCC are shown. I'm on local host, did not try on a live server.
Thank you

php mail function fail to send email to the domain based emails

Please find the code below. This code resides in mydomainname.com
mail("mymail#gmail.com,mymail#mydomainname.com","Testing mail","This is a test mail.","From: mymail#yahoo.com\n");
and
mail("mymail#gmail.com,mymail#mydomainname.com","Testing mail","This is a test mail.","From: mymail#mydomainname.com\n");
I am getting mail to my gmail account (or any yahoo account) for both code, but I am not receiving mail to my webmail or cPanel squirrelmail etc.
I can directly send email to this domain email account
Will the mail server of this domain prevents mails from same domain?
The code worked earlier for the same domainname.
Is it a problem with hosting side? It's a shared server.
Try this
<?php
$to = "admin#gmail.com,mymail#gmail.com";
$subject = "Following Customer Signed Up";
$message = " $username,Customer is signed up with us,<br /><br />
Thanks <br />";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
// More headers
$headers .= 'From: <mymail#mydomainname.com>' . "\r\n";
$mail=mail($to,$subject,$message,$headers);
?>

PHP mail() load image to email without having to click "Load all images"

When I create an email and send an image in the body of the email, most email clients make you click "Load all images" I want this to load automatically like a regular email would from any other company. Like an html email. This image is hosted on an external website, and is around 500kb-1.5mb and around 900x1200 size. How can I accomplish this? Is it just a header issue?
$from = "";
$headers = "From:" . $from ."\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$to = "";
$subject = "";
$subject = html_entity_decode($subject, ENT_QUOTES, 'UTF-8');
$message = '<html><head>';
$message .='</head><body>';
$message .='<img src="http://i45.tinypic.com/2qjkb2u.jpg"/>';
$message .= '</body></html>';
mail($to,$subject,$message,$headers);
You can't enforce this as it is not within your control. Email clients don't load images by default to protect the privacy of their users. (Spammers can track email addresses using images. The image is loaded via a server side script which confirms the email was received and viewed. Then spammers know the email address is valid and active). That's why it takes an active action by the user to actually view the images in the email.

To send email in Bcc to multiple users no "TO" user

I am tring to sent email to multiplw users in Bcc through PHP mail scriptcode is as follows -
$recipients =array('recpient1#gmail.com','recpient2go#gmail.com');
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$to = '';
$subject = "E-mail subject";
$body = "E-mail body";
$headers = 'From: info#mydomain.com' . "\r\n" ;
$headers .= 'Reply-To: info#mydomain.com' . "\r\n";
$headers .= 'BCC: ' . implode(', ', $recipients) . "\r\n";
$email =mail($to, $subject, $body, $headers);
if we leave $to black then user in gmail detail shows "to undisclosed recipients" and Bcc not shows how can be show "Bcc me (user who got mail)" i search a lot, but didn't got any proper answer
BCC stands for Blind Carbon Copy and its main purpose is, that you can not see the other recipients of that mail.
If you want to show all email addresses use CC (Carbon Copy) instead.
Be aware, though, that all recipients now can see all other recipients' email addresses, which increases the probabilities having those email addresses end up in spam catalogs.
You can't control how the people at Gmail decide to display the recipients list when reading an email. Each webmail system decides how they want to display the recipients list.
Maybe you can fin another webmail system that decided to display "Sent to me#my-email" instead of "Undisclosed recipients"...but why does it matter to you?
Why do you care about that? I'd say it is a false problem. Since you received the email, it was of course sent to you.

Categories