I want that email reply in php should be received at multiple email address. But it is not working for me. I have tried different ways but none of these working for me.
I am trying this header but it is only replying to the last email address.
$to = "recipientemail#address.com";
$subject = "my email subject";
$message = "my email message";
$headers = array();
$headers []= "MIME-Version: 1.0\r\n";
$headers []= "Content-Type: text/html; charset=UTF-8\r\n";
$headers []= "Reply-To: <" . $EmailAddress1 . "> <" . $EmailAddressss2 . ">" . "\r\n" ;
wp_mail($to, $subject, $message, $headers);
I have tried without braces as well but this one is also not working
$headers []= "Reply-To: 1st#address.com,2nd#address.com\r\n";
I do not have much idea about this so little guidance about this will be much appreciated. Thank you!
Related
I am trying to send an email from PHP.
The below code works fine when the From address is a Non-Gmail address.
However, when I use a Gmail address as a From Address, I don't receive the email. I have checked spam as well.
Can you tell any reason for this behaviour?
<?php
// validation expected data exists
if (!isset($_REQUEST['emailto']) ||
!isset($_REQUEST['emailsub']) ||
!isset($_REQUEST['emailfrom']) ||
!isset($_REQUEST['emailsub'])) {
exit;
}
$emailto = $_REQUEST['emailto'] ;
$emailsub = $_REQUEST['emailsub'] ;
$emailfrom = $_REQUEST['emailfrom'] ;
$emailmsg = $_REQUEST['emailmsg'] ;
// create email headers
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=utf-8\r\n";
$headers .= "From: " . $emailfrom . "\r\n";
$headers .= "Reply-To: " . $emailfrom . "\r\n";
$headers .= "X-Mailer: PHP/" . phpversion();
mail($emailto, $emailsub, $emailmsg, $headers));
?>
Thanks
In order to use some GMAIL.COM email address as FROM address, you must use GMAIL.COM SMTP server to send out emails. Your best shot is to use phpMailer as #biesior already mentioned.
Im trying to remember a trick i was taught a while back but can not.
Basically, im using PHP mail() in this fashion:
$to = "emailAddress1#domain.com";
$subject = "Welcome to BuildSanctuary";
$messageContent = "Thankyou for registering Bla bla bla";
$message = 'SOME HTML EMAIL STUFF including the $messageContent var';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To:' . "\r\n";
$headers .= 'From: Accounts<accounts#domain.com>' . "\r\n";
$headers .= 'Bcc: emailAddress1#domain.com,emailAddress2#domain.com,emailAddress3#domain.com,emailAddress4#domain.com' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
I got told a while back that there was a way that you could put your own email in the to field, but when the users receive the emails it looks like they were personally sent the email and the to field shows just their email.
Is this possible? Cant think how.
Thanks.
I am not sure if anyone can help me with this issues but I currently have a php mailing form. everything works great, I am trying to setup Cc options.
code.
$subject = "Name #$name_id test data";
$mailer ='Company <Support#company.com>';
$headers = "From: $mailer \r\n";
$headers .= "Cc: $cc \r\n";
$headers .= "Reply-To: ". strip_tags($mailer) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body style="background:#eeeeee">';
mail($emailto, $subject, $message, $headers);
cc var is $cc=$VAR["cc_user"]; which is linked to html form. so here is I enter an email address in the html input form and submit, it works. if I leave blank, email does not send. can anyone help me with this.
Thanks so much.
Fixed..
$emailto= $sql['CUSTOMER_EMAIL'].", ".$VAR["cc_user"];
I'm working with contact form
This is part where email is being sending
$emailTo = 'myemail#gmail.com';
$subject = 'Wiadomość ze strony Mud';
$sendCopy = trim($_POST['sendCopy']);
$body = "Email: $email \n\nKind of frame: $frame \n\nColor suggestion: $color \n\nInfo about project: $comments";
$headers = 'From: ' . ' <' . $emailTo . '>' . "\r\n" . 'Reply-To: ' . $email;
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=UTF-8\r\n";
mail($emailTo, $subject, $body, $headers);
// set our boolean completion value to TRUE
$emailSent = true;
Form works good everything is fine, except when I get mail and I want IN MY MAILBOX reply email it shows adress of my webserver
It looks like $headers dont work properly, If I'm right this part of code is responsible for reply adres email "'Reply-To: ' . $email;"
(IM NOT GOOD IN PHP)
And my second optional question is how to make stylish email.
I mean for example in my email when it comes to mailbox it shows
Email: dsadas#dsdas.pl
Kind of frame: dasdsa
Color suggestion: dasdsa
Info about project: dasdsa
How can I do it bold, color etc ?
THANK YOU FOR YOUR TIME, CHEERS
Here you go for headers that will allow HTML for email and fix your reply to email:
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-Type: text/html; charset=utf-8" . "\r\n";
$headers .= "From: $emailTo <$emailTo>" . "\r\n";
Remember that there is limited support for email when it comes to CSS, you can see things that can't be used here: http://www.campaignmonitor.com/css/
hay
i used this code
$to = "mial#live.com,mail#yahoo.com";
$subject = "Mini-mass Emailer";
$message = "<a href='#'>Hello World</a>";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Your Name <me#mydomain.com>' . "\r\n";
$headers .= 'Bcc: {$to}' . "\r\n";
if(mail($to, $subject, $message, $headers)){
echo 'ok';
}
but see what is happend
every user see the full list of the users
alt text http://img694.imageshack.us/img694/1289/21811933.gif
Your call to mail is passing the $to as the to parameter meaning those emails will be be in the to header try passing an empty string instead. You are passing the info into the bcc header so the email should still get to them that way.
That is because you have put all the users in the "to" line. You are also passing them into the "bcc" line too so just doing this may help you but as far as I know you need at least one address in the to line (although this may not be the case). It'll look pretty strange for each person doing it that way though.
The best way to avoid these issues would be to send the email multiple times, once to each user. To modify your code example to do this, I'd do something like the following:
$toAddresses = array("mial#live.com", "mail#yahoo.com");
$subject = "Mini-mass Emailer";
$message = "<a href='#'>Hello World</a>";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Your Name <me#mydomain.com>' . "\r\n";
foreach ($toAddresses as $to) {
if(mail($to, $subject, $message, $headers)){
echo "OK - sent message to {$to}";
}
}
The easiest way is to take this Mail-Class of phpguru.org:
http://www.phpguru.org/static/htmlMimeMail5
There you can specify with setBcc() the addresses which should be "blind", it's pretty easy and works well. I use this class in every project.
Best Regards.