verify domain sent email - php

How can I prove to email clients that the sent email was sent from the domain which the email was sent from? I have included the code I use to send emails.
$headers = "From: noreply#mydomain.com\r\n";
$headers .= "Reply-To: noreply#mydomain.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$to = $_GET['to'];
$subject = $_GET['subject'];
$message = $_GET['message'];
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);

Related

Send BCC with PHP mail() [duplicate]

I know there are a few similar questions to this but I just can't get it working.
Ok, I have a list of emails grabbed from my database in a variable called $emailList.
I can get my code to send an email from a form if I put the variable in the $to section but
I cannot get it to work with bcc. I've even added an email to the $to incase it was that but it doesn't make a difference.
Here is my code.
$to = "name#mydomain.com";
$subject .= "".$emailSubject."";
$headers .= 'Bcc: $emailList';
$headers = "From: no-reply#thepartyfinder.co.uk\r\n" . "X-Mailer: php";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body>';
$message .= 'THE MESSAGE FROM THE FORM';
if (mail($to, $subject, $message, $headers)) {
$sent = "Your email was sent!";
} else {
$sent = ("Error sending email.");
}
I've tried both codes:
$headers .= 'Bcc: $emailList';
and
$headers .= 'Bcc: '.$emailList.';
It's not that the emails aren't separated because they are. I know they are because it works if I put $emailList in the $to section.
I Should add, ignore the $message bits and the HTML stuff. I've not provided all of that so that is why it's missing from this code.
You have $headers .= '...'; followed by $headers = '...';; the second line is overwriting the first.
Just put the $headers .= "Bcc: $emailList\r\n"; say after the Content-type line and it should be fine.
On a side note, the To is generally required; mail servers might mark your message as spam otherwise.
$headers = "From: no-reply#thepartyfinder.co.uk\r\n" .
"X-Mailer: php\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= "Bcc: $emailList\r\n";
You were setting BCC but then overwriting the variable with the FROM
$to = "name#mydomain.com";
$subject .= "".$emailSubject."";
$headers .= "Bcc: ".$emailList."\r\n";
$headers .= "From: no-reply#thepartyfinder.co.uk\r\n" .
"X-Mailer: php";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body>';
$message .= 'THE MESSAGE FROM THE FORM';
if (mail($to, $subject, $message, $headers)) {
$sent = "Your email was sent!";
} else {
$sent = ("Error sending email.");
}

Undisclose recipients php without any extensions only mail() function

I am trying to not disclose the recipients when I send an email but I am failing on this:
$email = implode('; ', $email); // array where I have the emails
$to = $email; // webmaster#domain.com; webmaster#anotherdomain.com
$subject = 'Subject';
$headers = "From: noreply#domainfromwhereisendemail.com\r\n" . "X-Mailer: php\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= "To: Undisclosed Recipients <noreply#domainfromwhereisendemail.com>\r\n";
//$headers .= "Cc: $to\r\n";
$message =
<<<START
This is the message
START;
mail($to, $subject, $message, $headers);
I tried adding Cc or Bcc, but not working, it is adding besides the emails Undisclosed recipients. I am trying to do this without any other extensions, I checked a lot of questions from stackoverflow here but did not accomplish this. Emails are still being shown to each.
Nope you can't stop that from nondisclosure, unless you send the emails separately using a loop.
$email = implode('; ', $email); // <---- Don't do this.
The loop up way..
foreach($email as $mail) #<---- Use a foreach and loop through
{
$to = $mail;
$subject = 'Subject';
$headers = "From: noreply#domainfromwhereisendemail.com\r\n" . "X-Mailer: php\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message =
<<<START
This is the message
START;
mail($to, $subject, $message, $headers);
}
Here is the ôkio solution with a single call to mail():
$subject = 'Subject';
$headers = "X-Mailer: php\r\n";
# $headers .= "MIME-Version: 1.0\r\n"; # do you really need that?
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
foreach($email as $mail){
$headers .= "Bcc: ".$mail."\r\n";
}
$message =
<<<START
This is the message
START;
mail('non#existing.email', $subject, $message, $headers);

PHP email issue

I've a HTML signup form with php. After a successfully submit it sends a confirmation email to the user email address.
Well, when user see his/her email it's shown as:
Yoursite.comr#mediaplan.ovh.net
But I didn't add the #mediaplan.ovh.net part to the email address. Why it's showing in this address. #mediaplan.ovh.net? and how do i remove it?
php email code:
$to = "$email";
$subject = "Signup | Verification";
$message = "Congratulation $f_name $l_name you have been successfully registered.
Please click the link to active your account.\r\n";
$message .= "http://www.maaks.fr/hotel/verify.php?email=$email&hash=$hash\r\n";
$from = "Yoursite.com";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-rype: text/html; charset=iso-8859-1\r\n";
$headers .= "Content-Transfer-Encoding; 7bit\r\n";
$headers = "From:" . $from . "r\n";
$mailsent = mail($to,$subject,$message,$headers);
First, You are missing a slash in your from header part.
$headers = "From:" . $from . "r\n";
// ^ Here
Change From headers while sending the mail
$from = "WebsiteName <Your#mail.com>";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-rype: text/html; charset=iso-8859-1\r\n";
$headers .= "Content-Transfer-Encoding; 7bit\r\n";
$headers = "From: " . $from . "\r\n";
Try changing $from to email address.
$from = "noreply#yoursite.com";

PHP Email sending BCC

I know there are a few similar questions to this but I just can't get it working.
Ok, I have a list of emails grabbed from my database in a variable called $emailList.
I can get my code to send an email from a form if I put the variable in the $to section but
I cannot get it to work with bcc. I've even added an email to the $to incase it was that but it doesn't make a difference.
Here is my code.
$to = "name#mydomain.com";
$subject .= "".$emailSubject."";
$headers .= 'Bcc: $emailList';
$headers = "From: no-reply#thepartyfinder.co.uk\r\n" . "X-Mailer: php";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body>';
$message .= 'THE MESSAGE FROM THE FORM';
if (mail($to, $subject, $message, $headers)) {
$sent = "Your email was sent!";
} else {
$sent = ("Error sending email.");
}
I've tried both codes:
$headers .= 'Bcc: $emailList';
and
$headers .= 'Bcc: '.$emailList.';
It's not that the emails aren't separated because they are. I know they are because it works if I put $emailList in the $to section.
I Should add, ignore the $message bits and the HTML stuff. I've not provided all of that so that is why it's missing from this code.
You have $headers .= '...'; followed by $headers = '...';; the second line is overwriting the first.
Just put the $headers .= "Bcc: $emailList\r\n"; say after the Content-type line and it should be fine.
On a side note, the To is generally required; mail servers might mark your message as spam otherwise.
$headers = "From: no-reply#thepartyfinder.co.uk\r\n" .
"X-Mailer: php\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= "Bcc: $emailList\r\n";
You were setting BCC but then overwriting the variable with the FROM
$to = "name#mydomain.com";
$subject .= "".$emailSubject."";
$headers .= "Bcc: ".$emailList."\r\n";
$headers .= "From: no-reply#thepartyfinder.co.uk\r\n" .
"X-Mailer: php";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body>';
$message .= 'THE MESSAGE FROM THE FORM';
if (mail($to, $subject, $message, $headers)) {
$sent = "Your email was sent!";
} else {
$sent = ("Error sending email.");
}

Multiple recipient mail php not working for second onwards addresses

I have an HTML email needed to be sent to more than one person:
$mem = "abc#def.com, qwr#rty.com";
$subject = 'Invitation to Party';
$headers = "From: info#example.com\r\n";
$headers .= "Reply-To: info#example.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = "SNIPPED";
mail($mem, $subject, $message, $headers);
It is sending to the first email which is abc#def.com, but it's not sending mail for the second recipient which is qwr#rty.com and the rest.
The email addresses are examples.
Is there any work-around for this besides using library?
you may send the second id as a bcc,
$headers .= "Bcc: ".$bcc."\r\n";

Categories