PHP mail() sends header with dedicated server domain - php

When I send mail via PHP's mail() it sends the wrong header information...
$to = 'mypersonal#gmail.com';
$subject = 'the subject';
$message = 'hello, hi :)';
$headers = 'From: Support <support#site.com>' . "\r\n" .
'Reply-To: From: support#site.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
in my gmail it shows
Support via mydedicatedserver.dediprovider.com
How can I configure PHP mail() to send my domain name?

mail() is already sending your domain name.
Gmail sometimes displays that message when Google is not familiar with your server and the hostname of your server does not match the domain name you're sending e-mail from. It's an anti-spam/anti-phishing measure.
Add proper SPF records to your domain. If the server is under your control, try changing its hostname to something that includes your domain name, like server1.site.com. Follow all other advice listed in the link below. Even then, there is no guarantee that Gmail will drop the message right away. In my experience, that message goes away after a while when Google becomes familiar with e-mails from your server and decides that none of them are spam. But Google seems reluctant to disclose exactly what is required, probably because they don't want spammers to get too clever.
See: https://support.google.com/mail/bin/answer.py?hl=en&answer=1311182
Also, the Reply-To: From: header is wrong.

Related

php domain mail receiving issue

I am using php mail function its working fine for gmail but when i send it to domain email it show me successful message but not receive on my domain email side where i am wrong. my code is below
<?php
$to=$_POST['to'];
$from=abc#gmail.com;
$name="abc";
$subject=$_POST['subject'];
$message=$_POST['message'];
$headers = 'From:'. $name ."\r\n" .
'Reply-To:'. $from . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers,"-f".$from);
echo "Message sent! <a href='mail.php'>Click here</a> to send another email.";
?>
my domain email is contact#automailer.netai.net how can i fix this issue,
There are two completely different processes involved:
Queueing the mail to your local MTA (This is what PHP's mail() does)
This MTA delivering (with possible hops in between) to the final MTA, which delivers into the users mailbox
Obviously PHP only knows about the first step and may be right to consider it successfully done even if something else later goes wrong - e.g. the receiver domain simply not accepting your mail (which sadly is the new normal).
most likely automailer.netai.net is blacklisted and that's why you aren't getting emails.
try using phpMailer library which is free or popular smtp api that offer free trial as long yo don't pass 10,000 emails per month from
sendgrid.com,
maildrill, etc

MY SMTP mail keeps coming through as Junk

I know this is plastered all over the net... But i've tried a lot of solutions and it just wont seem to work. My SMTP mail first came through as junk, and now just comes into my inbox, but with a warning notice saying the email didnt pass the fraud tests..
So im using Optus's SMTP server (mail.optusnet.com.au), and for the "sendmail_from" i have my email address..
for the actual mail, i have this:
$message = 'Hello, $user;
$to = 'nobody#example.com';
$subject = 'Welcome';
$headers = 'From: myemail#hotmail.com' . "\r\n" .
'Reply-To: myemail#hotmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail('myemail#hotmail.com', $subject, $message, $headers);
Any ideas guys?
Thanks,
Adam
Most of E-Mail providers check every received email to decide whether it's a spam or not. For example , if you send an email as myemail#hotmail.com from mail.optusnet.com.au , it will not pass the test and will be put under junk category. In my experience, Yahoo! and Hotmail usually put every email with X-Mailer: PHP header as junk!
For more information take a look at Sender Policy Framework.
About comment:
If you take a look at your received email, you will see something like this:
Received-SPF: neutral (google.com: x.x.x.x is neither permitted nor denied by best guess record for domain of email#mail.optusnet.com.au) client-ip=x.x.x.x;
it tells client that this email at least is NOT trying to show itself as someone else, so it goes to your inbox. but If you use something#hotmail.com, since hotmail.com has a valid IP and it's different from mail.optusnet.com.au, so it goes to your junk folder.

Send multiple emails using PHP

I working on a project in which i need to develop a functionality to send multiple emails to client with one click and i am adding customer id in one text box separating them with comma.
Please tell me how to do this problematically. Your advice
<?php
$to = 'nobody#example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster#example.com' . "\r\n" .
'Reply-To: webmaster#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
if you want to send the user as in db jus replace the $to address from db and place these code in loop.
php.net's mail function page explains this well
to be fair we all had to start somewhere. The problem with using "vanilla PHP mail" is that it is almost always used when people send mail as spam. So for 10 years mail servers haven't liked it. There are ways round it but to be brief:
To send Email via a webpage you "should"
have your mail server resolve RDNS
try to avoid cheap/free web hotels as mailserver hosts
use PHP PEAR MAIL (this is tricky/odd to install)
properly apply the correct headers for the mail in PEAR
Check below link may be help you.
http://www.quackit.com/php/tutorial/php_mail.cfm

Sending email from domain different than primary? Possible?

this may be a noobish question. I'd like to know if I can send emails from the server that say, domain1.com is associated with, as coming from domain2.com and also having the origin show as coming from domain2.com?
The reason I'd like to do this, is because I have an application I'm developing and would like to send emails from the domain, for example - maildomain.com instead of coming from domain.com
Emails are being sent with php's mail function.
Yes, you can:
$to = 'nobody#example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster#example-two.com' . "\r\n" .
'Reply-To: webmaster#example-two.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
You should set up some things, so the receiver doesn't mark it as spam though:
Set up DNS MX records with low priority for the receiving domain, pointing to sending server
Setup correct reverse DNS entries for sending server
..
The "From" address in an email is entirely arbitrary. As long as you have permission to submit mail to a server's queue, you can put any From address in it that you want. president#whitehouse.gov, julian#wikileaks.org, etc.
To do this with PHP's mail() function, use *$additional_headers*. For example:
$to = "whoever#example.com";
$subject = "This is an example!";
$message = "Hello,\n\nThis is message body.\n\nIsn't that nice?\n\n";
$headers = "From: El Presidente <president#whitehouse.gov>\r\n"
. "X-foo: bar\r\n";
$result = mail($to, $subject, $message, $headers);
Possible? Yes is sure is. See the below example from PHP.net. However, I'm going to put a little piece of fine print here, as I think you might run into some trouble, and I want to make it easier for you in the future. ;) Your current webhost may block this, I've never seen it, but I've heard it can happen. Also, there is a thing called SPF, or Sender Policy Framework, that is a DNS record that you can set to determine what servers can send on your behalf. Many servers that could receive your mail, and especially GMail check for valid SPF. All you have to do is add a TXT record on your name server for domain.com. It should look something like this: v=spf1 mx a:maildomain.com -all. This says any records that have an MX record set up, and the IPs that are resolved from maildomain.com are valid 'non-spam'. Also, you will to fail any other mail origin.
<?php
$to = 'nobody#example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster#example.com' . "\r\n" .
'Reply-To: webmaster#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
If the mail server is an open mail relay then yes, you can send from a different domain. It is of course seen as a vulnerability as spammers can use it to send out junk mail. The configuration of the mail server to get this functionality depends on its platform but you can usually test a server's ability to freely relay messages by telneting to the server on port 25 and doing an ehlo test.

Email form isn't sending

I have an email form that isn't sending out an email to the recipient or a copy to the client. The form can be found at www.kelcos.co.uk/contact and the files associated with this are:
/index.php
/jquery.js
/sendemail.php
/submitform.php
/thanks.php
/verify.php
I have used this form on other websites http://www.bowlesgreen.co.uk/contact/ and http://www.arbortectreecare.co.uk/contact/ and it works fine - the only difference is that these other sites use my usual hosting provider and for the one that won't send I'm working through the clients hosting provider, which I can only presume is what is causing the problem.
I have contacted the hosting and so far we have eliminated a few things such as:
'The limitation to our systems is that the emails sent using scripts will be blocked if they are not going to or coming from an email address setup on the web hosting account. - so I am now sending the form to an a kelcos.co.uk address, but still no joy.
PHP/ASP was originally disabled, but now has been activated
the mail() script is enabled
I would really appreciated any advise any of you could offer.
Thanks
No, http://www.bowlesgreen.co.uk/contact/ doesn't work fine as you said. Firebug reports: POST http://www.bowlesgreen.co.uk/projects/wp/wp-content/themes/bowlesgreen/contactform/sendemail.php 404 Not Found
Your forms are submitting to the wrong URL.
Is Qmail available on the server? Are you setting the headers properly?
Try something like the following:
putenv ("QMAILUSER=myuser");
putenv ("QMAILNAME=My Name");
putenv ("QMAILHOST=mydomain.com");
$headers = 'From: My Name <myname#mydomain.com>' . "\r\n" .
'Reply-To: My Name <myname#mydomain.com>' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$mail_to = 'myemail#myemail.com';
$subject = "Testing email";
$body = "This mail is a test";
mail($mail_to, $subject, $body, $headers);
And see if you receive an email!
try these
http://forum.codecall.net/php-forum/28696-php-contact-form-isnt-sending-out-email.html
http://www.astahost.com/info.php/Php-Send-Email-Problem_t2259.html

Categories