I am trying to figure out how I can change what shows up for my company when I send out php emails. Right now this shows up:
I don't want it to say newsletter, I want it to say my companies name. I don't have anything in my code that says newsletter, so I am unsure of why that is even displaying, unless it just naturally takes what comes before the # in the email address. newsletter#companyname.com
What can I change in my code, so it reads my company name in the area I showed in the image, similar to what Amazon does, minus the .com.
$to = $newsletter_email;
$subject = 'Thank you for subscribing to the Newsletter';
$message = '
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Newsletter</title>
</head>
<body>
</body>
</html>
';
$from = "newsletter#companyname.com";
$Bcc = "newsletter-notification#companyname.com";
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: ' .$to. "\r\n";
$headers .= 'From: ' .$from. "\r\n";
$headers .= 'Bcc: '.$Bcc. "\r\n";
// Send the email
mail($to,$subject,$message,$headers);
Try
$from = 'My Company <newsletter#companyname.com>';
I think the problem is the way Gmail is displaying the name of the person when it's not specified.
Check what's in your sendmail.ini and php.ini:
sendmail.ini
force_sender=<email>
php.ini
sendmail_from=<email>
Related
i have try to send mail with russian name but its not working on outlook but showing correctly on gmail.. how can i fix it.. it show like this
ÐоÑÑале [info#stackoverflow.com]
i have try following code $subject = mb_encode_mimeheader('Потцале',"UTF-8");
but after this gmail also show same problem.. russian character display well on the body section but not on header of mail.
here is my code..
<?php
// if the url field is empty
$emails='info#stackoverflow.com';
$email='xyz#gmail.com';
$con='Потцале Потцале Потцале Потцале';
$subject = mb_encode_mimeheader('Потцале',"UTF-8");
$msg='<html><head><meta http-equiv="Content-Type" content="text/html;
charset=utf-8" /></head><body>Потцале Потцале Потцале Потцале </body></html>';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .='Content-Transfer-Encoding: base64' . "\r\n";
$headers .= 'From:'.$subject.'<'.$emails.'> ' . "\r\n";
// then send the form to your email
$ash = #mail( $email,$con,$msg,$headers);
// #mail( $email,'Submit Form','Thanks For Contacting Us We Will Contact You Shortly',$headers);
if($ash)
{
echo 'send';
}
else
{
echo ' Not Send send';
}
?>
<html>
Thanks!
Thanks
We'll get back to you as soon as possible.
after subject.. please help me ..
I'm getting this error Warning: mail() Multiple or Malformed new lines found in additional header... I have tried giving the $message variables a different variable name, but nothing I do works.
There error is coming from the last line that I posted in this..
mail($to,$subject,$message,$headers);
Full code
$to = $approved_email;
$subject = 'There is a new user request to join the ';
$message = '
<html>
<head>
<title>New User Request</title>
</head>
<body>
<p>Hi '.$approved_firstname.',</p><br>
<p>Your Account has been accepted. You have been added to the group. To sign in, click this link
http://example.com . </p><br>
<p>Thank you,</p>
<p>Administration</p>
</body>
</html>
';
$from = "user-requests#example.com";
$Bcc = "user-requests-confirm#example.com";
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: ' .$to. "\r\n";
$headers .= 'From: ' .$from. "\r\n";
$headers .= 'Bcc: '.$Bcc. "\r\n";
// Send the email
mail($to,$subject,$message,$headers);
I have a similar email in another file and it works. What could be the problem?
I'm trying to test if the return-path will bounce back on my gmail, but not.
I'm testing to send it to my email (enalds#gmail.com): it works!
And send to unknown email (gifjgogsdkg#fafasfsa.com): it didn't bounce back.
Here's my code
<?php
$message = '
<html>
<head>
<title>Sample Email</title>
</head>
<body>
Sample Email
<br /><br />
Click here to Unsubscribe
</body>
</html>
';
$sender = "enalds#gmail.com";
$email_address = "sender_name#yahoo.com";
$subject = "Testing Email";
$template_name = "Sample Email";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'Return-Path: enalds#gmail.com' . "\r\n";
$headers .= 'From: '.$sender.'' . "\r\n";
if(mail($email_address, $subject, $message, $headers, '-fenalds#gmail.com'))
echo "{$i}. {$email_address} - <span style='color:green'>Successfully</span> Sent [{$template_name}]<br />";
else
echo "{$i}. {$email_address} - <span style='color:green'>Unsuccessfully</span> Sent [{$template_name}]<br />";
You have two solutions to this issue:
First one is leave blank in the php.ini configuration file the "sendmail_from" variable.
This way you could add the additional parameters in the mail function like you have in your code.
The second approach, is set "sendmail_from" in php.ini if you want to have always the same "Return-Path" for every email.
This question already has answers here:
PHP: Html send email in html format
(2 answers)
Closed 8 years ago.
I want to send email in php with some HTML.
In my email, it's giving me like,
Hello <strong>,</strong><br><br>
It's not basically parse HTML code. Instead of effect, it's printing html tags.
This is my email function:
mail("$user_email","ESubject","$message","From: Name");
Message variable:
$message = "Hello <strong>,</strong><br><br>
To verify your email and complete your registration please click on the link below: <br /><br />
<a href='<?=$link?>'>VERIFY ACCOUNT</a>";
You need to set the Content type : text/html on your header !
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
and add it to your mail()
mail($to, $subject, $message, $headers); //<--- Like that.
Note:
If intending to send HTML or otherwise Complex mails, it is recommended to use the PEAR package » PEAR::Mail_Mime.
Source : PHP.net
EDIT :
Just do it this way
$message = "Hello <strong>,</strong><br><br>
To verify your email and complete your registration please click on the link below: <br /><br />
<a href=$link>VERIFY ACCOUNT</a>";
For better understanding please refer below script:
<?php
$to = "somebody#example.com, somebodyelse#example.com";
$subject = "HTML email";
$message = "
<html>
<head>
<title>HTML email</title>
</head>
<body>Hello <strong>,</strong><br><br>
</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: <webmaster#example.com>' . "\r\n";
$headers .= 'Cc: myboss#example.com' . "\r\n";
mail($to,$subject,$message,$headers);
?>
I am trying to create mailing function like gmail and yahoo, where we can enter multiple id in to,cc,bcc fiels to send multiple mails but not able to do so. I can send single mail with attchment on only one mail id,but not to multiple mail ids in to ,cc ,bcc. I am using texboxes to add mail ids
Can any one help me.
It depends on your definition of 'Bulk'. If you're talking 100s of emails, you should use a batched mail sender as advised on php.net/mail. There are a few PHP options but I'd suggest something that will allow you to do background processing so as to not hold up your script.
If you're just doing this for a few recipients, you can inject Bcc and Cc headers into your email message when using mail(..). There are full examples on the php.net page linked above.
A (copied from documentation) example is below:
<?php
$to = 'aidan#example.com' . ', '; // note the comma
$to .= 'wez#example.com';
// subject
$subject = 'Birthday Reminders for August';
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
.. snip
</body>
</html>
';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To: Mary <mary#example.com>, Kelly <kelly#example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday#example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive#example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck#example.com' . "\r\n";
mail($to, $subject, $message, $headers);
?>