MY SMTP mail keeps coming through as Junk - php

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.

Related

Can't figure out why SMTP email does not work to the same domain it's sending from

I have a PHP customer input form which sends out SMTP mail to the company hosting the form. For some reason the emails are not reaching the recipient's email. If I substitute in any other email address not on the domain it works out fine. I can also list multiple addresses on the To: line and the others will get the email but not the desired info# email address. I cannot change the sending domain since my web hosting won't send mail when they are mismatched. I thought that it might have to do with the sending email address and receiving being the same so I changed the From: address to "onlineform#" instead of "info#" but that made no difference.
I'm perplexed as to what's happening here. I can send email directly from any other account to the "info#" email address and that works fine. I've asked them to check their client and server junk mail folders and they are both clean. Any ideas on what's going on or how to further diagnose the issue? I've simplified the code down to the relevant parts below and the snippet code does the same thing.
<?php
$email_to = "info#domain.tld";
$email_subject = "Subject line here";
$email_message = "Email body here.";
$headers = 'From: onlineform#domain.tld'."\r\n".
'Reply-To: noreply#domain.tld'."\r\n" .
'X-Mailer: PHP/' . phpversion();
#mail($email_to, $email_subject, $email_message, $headers);
?>
It could have something to do to the server's mail policy. You may be telling the server that the message is being sent from whatever#domain.tld, but you are not proving it.
Have you tried to send using SMTP authentication? Not sure this is actually the real problem, but it worth testing.
Also, I recommend you to always use mail solutions instead of using the plain php mail() function. I've used PHP Mailer for a long time and not only it works fine, it always eased the boring process of sending e-mails through php.

How can i get rid of the server name when sending a mail with php

Whenever i use php to send a mail the receiver gets something like this "From: Website plc info#website.com via mirage.arandomserver.com "
How can i get rid of the server name totally?
Here's my current script"
$to="$Email";
$subject="Message received";
$headers= 'From: Website plc <info#website.com>' . "\r\n" .
'Reply-To: $Email' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$contact_message="
Dear $FirstName $Surname,
message
Thanks
P&C Group Careers
http://www.career.pandcgroupng.com
";
mail("$to", "$subject", $contact_message, $headers);
Use the "envelope from address" additional parameter.
mail($to, $subject, $contact_message, $headers, '-f info#website.com');
This address will be used internally by the mail system for routing purposes. Note this also bypasses some problems with mail filter software detecting "bad" from addresses that don't match the actual originating server.
EDIT - I have absolutely no experience with this on Windows.
The "via mirage.arandomserver.com" appears when Gmail was unable to verify the "website.com" is actually sending the email. Gmail checks a lot of factors including reverse DNS, SPF records and/or the HELO from the sending SMTP server to verify the server is allowed to be sending as that domain. Has nothing to do with your actual PHP script.
Take a look at Google's documentation on this: http://support.google.com/mail/answer/1311182
Check your SPF records on the "website.com" domain, and ensure they are correct for the email server you are sending from. You may want to talk to the hosting company, or system administrator to get the correct SPF record you need for your hosting setup.
You can't. Your server is involved in the SMTP communications and will always be visible in the raw mail message as a header similar to this:
Received: from example.com (example.com. [100.100.100.100])
by mx.google.com with ESMTP id t8si14713688dfb.115.2013.03.18.10.01.59;
Mon, 18 Mar 2013 10:01:59 -0700 (PDT)
Because of this mail clients like GMail will show the "via" part you are seeing.

PHP mail() sends header with dedicated server domain

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.

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