I am sending email using mail() The problem is I am not getting an email to a specific email id if the recipient id does not exists, I have tried the following code.
$email="abcdt01est#gmail.com";
$usermsg="some message here";
$subject = 'Your Account Registration Confirmation';
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "From: Our Team <team#test.com>" . "\r\n";
$headers.="Return-Path:<my email id goes here>\r\n";
mail($email, $subject, $usermsg, $headers);
I have also tried with
mail("abcdt01est#gmail.com", "subject", "body of message", "From: team#test.com", "-f<my email id>");
Mail function in PHP mail() only informs about E-Mail has been accepted by the outgoing server, and plays no role in checking E-Mail's actual delivery status.
You can check your mail log /var/log/mail.log if sendmail is configured properly.
Visit this http://www.phpclasses.org/package/9-PHP-PHP-mailer-to-compose-and-send-MIME-messages.html - MIME E-mail message sending: PHP mailer to compose and send MIME messages.
Related
I am trying to send mail to multiple recipient without them seeing each others email address
this is what I have done so far
//my variable $mailto got all the emails from the database
$mailto = preg_replace('#\s+#',',',trim($mailto));
$headers = 'FROM: COMPANY INC <support#admin.com>\r\n';
$headers .= 'BBC'.$mailto."\r\n";
$headers .= 'Content-Type:text/html; charset=ISO- 8859-1\r\n';
mail($mailto, "MY TITle", $mailbody, $headers);
You are setting the wrong header. There is no BBC, and you're missing a colon.
try
$headers .= 'BCC: '.$ml."\r\n";
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
We have a confirmation script for our users, which uses the PHP mail() function. If I enter my own address (GMail or Yahoo) everything works perfectly. If however I enter the client's address, the function returns 1 but the email never reaches its destination. We checked spam but the email is not there either.
This is the PHP script I prepared:
$msg = "Body of the message";
$headers = "From: OUR TEAM <team#our_email.com>\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$sendmail = mail('some#address.com', 'Trial email (testing...)', $msg, $headers);
echo ("Sent mail = ") . $sendmail;
The return value is always 1.
Is there a way around this?
Thanks.
I have a php form that I made and when someone fills out the form it works fine with all other email accounts (yahoo, hotmail, #mydomain.com, etc) but when it comes to sending the email to a gmail user, the email never comes through, not even in the spam box.
$from = $email;
//Testing Below
//$headers = 'From:noreply#mydomainname.com' . "\r\n";
$headers .= "From: $from \n";
$headers .= " MIME-Version: 1.0\r\n ";
$headers .= " Content-Type: text/html; charset=ISO-8859-1\r\n ";
//Mail The Message
mail($to, $subject, $message, $headers);
The code above will not send to gmail but will work for all other email accounts. This one (below) will work for gmail but of course then I don't have the option of html in the email.
$headers = 'From:noreply#mydomainname.com' . "\r\n";
//$headers .= "From: $from \n";
//$headers .= " MIME-Version: 1.0\r\n ";
//$headers .= " Content-Type: text/html; charset=ISO-8859-1\r\n ";
//Mail The Message
mail($to, $subject, $message, $headers);
So basically when I add the MIME and Content type to the headers variable it wont send to a gmail account.
Thanks in advance!
I have replied a question not too long ago related to this. It might have to do with the gmail's email filtering, maybe you are getting too high spam score so it's not even getting into the spam folder, this could be caused by not having correct dns configuration / keys and trying to use html at the same time.
I leave a link to the other answer (It's quite long, and not as easy as you would imagine xD):
PHP and Gmail spam filter
Hope it helps you.
You are not using a proper concatenation operator:
Change your From line to:
$headers .= "From: ".$from;
I want to make an email forwarder similar to cPanel's, where I have a database of email addresses, and where they should forward to, and I set a catch-all to pipe to my script.
I have completed this script, however, I would like to make the "To:" field in the header show the address it was sent to, rather than who is was being delivered to. For example, the email was sent to user001#mydomain.com, and the script forwards it to me#gmail.com. How can I make PHP send mail to me#gmail.com, but still show user001#mydomain.com in the headers, like cPanel does?
You can use the headers of the mail function:
$to = 'me#gmail.com';
$subject = 'Testing';
$message = 'This is a test';
$headers .= 'To: User001 <user001#mydomain.com>, User002 <user002#mydomain.com>' . "\r\n";
$headers .= 'From: My Email Script <me#gmail.com>' . "\r\n";
mail($to, $subject, $message, $headers);