Hotmail account can't receive email sent by Godaddy - php

I have tried to make an email service on my web site, but after I tried the code below, I find that my Hotmail account cannot receive the test email but others are fine (Gmail and Yahoo). I am using Godaddy hosting. Please help.
My code:
<?php
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->setFrom('example#example.com', 'example');
$mail->addAddress('myemailid#hotmail.com', 'myname');
$mail->Subject = 'PHPMailer mail() test';
$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
$mail->AltBody = 'This is a plain-text message body';
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>

I had the same issue in the past and the solution was to apply for ip Whitelisting. Here's the steps to do that.
Step 1
Browse to the Hotmail Postmaster website
Step 2
Click on the link for "Email I send is being blocked or junked by Hotmail." You'll be redirected to the Hotmail Live Troubleshooting page.
Step 3
Review the troubleshooting guide to diagnose a problem. Email from your IP address might be automatically identified as junk mail for a number of reasons. Dynamic IP addresses may have been used by other parties for spam, or the DNS entry for your domain might not show up as legitimate to Hotmail servers. Identify and address the issues causing your email to Hotmail users to be blocked as junk.
Step 4
Fill out an application to the Junk Mail Reporting Program . This will help Hotmail identify your mailing domain and add it to a whitelist.

Related

Send email using PHPMailer without SMTP authentication

I don't use PHP that often but when I do and I need to write a function to send E-Mails, I just used the mail() function. I have used it on a shared hosting service and I always received the E-Mails from a... well... not an account? A bot? It didn't even have an E-Mail address.
And that's what I want to achieve at this very moment - send an E-Mail to me without really connecting to a SMTP server or going through authentication. How can be that done with PHPMailer? Is it even possible in my case? And if you somehow got my question, how are such E-Mails even called; the ones that... aren't sent by... well... an E-Mail account?
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'PHPMailer-master\src\Exception.php';
require 'PHPMailer-master\src\PHPMailer.php';
require 'PHPMailer-master\src\SMTP.php';
$mail = new PHPMailer();
$mail->FromName = "A random name";
$mail->addAddress("myemail#gmail.com", "Recepient Name");
$mail->isHTML(true);
$mail->Subject = "Subject is here";
$mail->Body = "Hello, <br>test body ";
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}
?>
This did make me laugh a bit...
No, emails can't just magically spring into existence, but there isn't necessarily a direct correlation between email user accounts and addresses.
When you send from a shared hosting account by calling mail(), the mail server knows the account you're sending from, and sometimes doesn't require authentication as a result. This for example is how GoDaddy operates. Unfortunately this approach is very prone to abuse because there is often little preventing you from flat-out lying about who you are. This is why such services are usually a) terrible and b) extremely unreliable for actually delivering messages.
If you don't specify a "from" address, the server will usually make one up from information it does have – typically your user account name, or the name of the user running the script (e.g. www-data), and the hostname of the server you're on, often something like randomnumber.hostingprovider.example.com. Look at the headers of messages you've sent before, and you'll probably see something like that.
Sometimes this address can be the same for all users on a given shared server, so your delivery reputation can depend on what others are sending, which could well be spam, phishing, malware, etc.
This vagueness is terrible for deliverability, so if you host your contact form on such a system, expect messages from it to end up in a spam folder.
If you use SMTP to send via a "proper" account you gain a lot more control and reliability, but unfortunately some hosting providers (GoDaddy again) block outbound SMTP and force you to use their mail servers. This is a way of saying that if you want to send email that will be delivered, use a decent hosting provider.
Once you get control over your sending, you can choose exactly what addresses messages are sent from, subject to authentication constraints including things like SPF, DKIM, and DMARC, but that's another story.
To my knowledge it is possible and have it work correctly each time. In the last year I found that the e-mails I sent using the mail() function would immediately go into my spam box (as well as the junk box of others) causing great confusion. I upgraded to PHPMailer to solve this and I have never set it up to use SMTP and works just fine.
The code I have is:
$mail = new PHPMailer(true);
$html = $email->get(); // This gets a standard HTML Template to use as the base of the e-mail.
$title = 'Title for Inside the HTML';
$subject = 'The E-mail Subject';
$html = str_replace('[title]',$title,$html); //Use this to replace the [title] element in my HTML Template with $title.
$html = str_replace('[date]',date("F j, Y g:i A"),$html); // Again, replaces [date] in the HTML Template with the current date and time.
$body = 'Hello My Good Friend,<br>This is just a simple <strong>HTML Message</strong><br><br>Thank you.';
$html = str_replace('[body]',$body,$html); //Add my HTML Message to the HTML Template.
try {
//Recipients
$mail->setFrom('noreply#example.com', 'My Organization');
$mail->addAddress($row["email"], $row["fullname"]); // Add a recipient
//Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $subject;
$mail->Body = $html;
$mail->AltBody = strip_tags($html,'<br>');
$mail->send();
//Return Success Message
$rMsg .= '<div class="alert alert-success">
<strong>Success: </strong> We have e-mailed the warning.</div>';
} catch (Exception $e) {
$rMsg .= '<div class="alert alert-danger">
<strong>Error: </strong> There was an error e-mailing the warning.</div>';
}

Sending Email using godaddy smtp relay and PHPMailer on codeigniter [duplicate]

This question already has answers here:
can't send email to addresses at my own domain
(19 answers)
Closed 6 years ago.
I am trying to reset password mails to client users. I am using a helper function which is called from the controller to send emails.
function submit_email($to,$subject,$message)
{
$CI = get_instance();
$CI->load->library('My_PHPMailer');
$mail = new PHPMailer();
$mail->Host = "relay-hosting.secureserver.net";
$mail->Port = 465;
$mail->SetFrom('info#domain.in', 'Saurabh Pradhan');
$mail->AddReplyTo("info#domain.in","Saurabh Pradhan");
$mail->Subject = $subject;
$mail->Body = $message;
$mail->AltBody = "Plain text message";
$destino = $to;
$mail->AddAddress($destino, "John Doe");
if(!$mail->Send()) {
$data["message"] = "Error: " . $mail->ErrorInfo;
} else {
$data["message"] = "Message sent correctly!";
}
var_dump($data);
}
Scenario 1 (Working): If the to address is my personal gmail.id eg. pradhansp#gmail.com than the email is delivered fine.
array(1) { ["message"]=> string(23) "Message sent correctly!" }
Scenario 2 (Not Working): If the to address is client domain info#domain.in than also i got the success message but mail is not delivered.
An important point here is that client domain is hosted on godaddy however for email he is using google apps for work. I already looked at the MX entries on the godaddy account and they are pointing correctly to google.
Priority | Mail Server
1 | ASPMX.L.GOOGLE.COM.
After a lot of attempts with different solutions I finally manage to get it working with the help of answer to following listed question. Thanks to #Vicm
can't send email to addresses at my own domain
Used following steps to Add the MX records into the cPanel:
Enter into the cPanel
Go the the cPanel Mail section
Search for MX Entry Maintenance, sometimes there is no text above
the icon.
Select the related domain
Change Email Routing to Remote Mail Exchanger.
Add all the google MX records as they are in your domain
configuration using the appropriate priority values. You can check
the records here and priorities
https://support.google.com/a/answer/174125
Double check that Remote Mail Exchanger. is selected.
With this setting I was able to send email using PHPMailer to an email account with in godaddy domain.
Google App instructions talking about MX records https://support.google.com/a/answer/54717?hl=en

Unable to send an email at hotmail from CRM

We unable send an email from CRM at hotmail. We use google app as email host. Our custom applications PHP by our own developer. We able send email at every domain like yahoo, AOL and other domain except hotmail account.
We checked our PHPMailer script and also run google smtm but nothing is working. Please help me out of this issue.
<html>
<head>
<title>PHPMailer - Mail() basic test</title>
</head>
<body>`enter code here`
<?php
require_once('../class.phpmailer.php');
$mail = new PHPMailer(); // defaults to using php "mail()"
//$mail->IsHTML(true);
//$mail->CharSet = 'windows-1251';
$body = 'This is ....';
$mail->AddReplyTo("task#mytasker.com","Mytasker1");
//$mail->SetFrom('deep_m#outlook.com', 'Deep');
//$mail->SetFrom('saikat_mytasker#hotmail.com', "Saikat Mallick");
$mail->SetFrom("task#mytasker.com","Mytasker");
$address = "saikat#mytasker.com";
//$mail->AddAddress('saikat_mytasker#hotmail.com', "Saikat Mallick");
$mail->AddAddress('deep_m#outlook.com', 'Deep');
$mail->AddAddress($address, "Saikat Mallick");
$mail->Subject = "Mytasker 123 ...";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
//$mail->AddAttachment("images/phpmailer.gif"); // attachment
//$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
</body>
</html>
This is probably hotmail servers are classifying your email content or servers as spam and is auto blocked. Though this is a little off topic but may i suggest to switch to third party email senders such as mandrill or mailjet. In this way, you will mitigate the risk of your content / servers being classified / marked as spam and ensure 99.99% hitting inbox rate

Getting warning message in Gmail Account when I send email by using phpmailer()

I am using phpmailer() to send email from my website. But when It's sent email I see following warning message.
I can't understand why it's showing and how can I fix this error message. Can anyone tell me about it ?
Following is my code :
<?php
require_once("mail/PHPMailerAutoload.php");
$mail = new PHPMailer;
$mail->setFrom($email);
$mail->addReplyTo('toemail#gmail.com', 'First Last');
$mail->addAddress('toemail#gmail.com', 'First Last');
$mail->Subject = 'PHPMailer mail() test';
$mail->msgHTML(file_get_contents('mail/contents.html'), dirname(__FILE__));
$mail->AltBody = 'This is a plain-text message body';
$mail->addAttachment('mail/images/phpmailer_mini.png');
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
Easy, you could read about SPF DNS Record.
When you send and email, services like gmail check if the sender ip is the same that the domain of the email, for example:
You send an email as "foo#gmail.com" to "bar#hotmail.com". Your
server ip is 1.1.1.1
Hotmail receives an email from "foo#gmail.com" so check if gmail.com
ip (2.2.2.2) is the same as your server (1.1.1.1). The answer is NO,
so the email is marked as spam.
To avoid that your email will marked as spam, you could use
phpmailer using a real google account and provide phpmailer the user
and password to send the email.
I tried to explain you the situation very easy on point 2. Real situation is a bit complicated but the logic is the same, check ip sender and origin. Read about SPF (and dkim) because is what are you looking for :)
http://en.wikipedia.org/wiki/Sender_Policy_Framework

Account confirmation email sent as SPAM

I am using PHPMailer to send a confirmation email for newly registered users in my social network. But I found out most of them have ended up in user's spam list. (Hotmail and Yahoo). How to avoid this?
This is my script
$mail=new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = mSMTPAuth();
$mail->SMTPSecure = mSMTPSecure();
$mail->Host = mHost();
$mail->Port = mPort();
$mail->Username = mUsername();
$mail->Password = mPassword();
$mail->From = mFrom();
$mail->FromName = "SiteName";
$mail->Subject = "SiteName New Account Activation";
$mail->IsHTML(true);
$mail->WordWrap = 50;
$mail->Body = "<h2>Welcome to " .$sitename. " " .$username. "! </h2><br><br>";
$mail->Body .= "Please click on the link below to verify your email address:<br><br>";
$mail->Body .= "<a href='".$base. "verify.php?a=" .$gen_key."'>".$base. "verify.php?a=" .$gen_key."</a>";
$mail->Body .= "<br><br>Regards<br>";
$mail->AltBody = "Welcome to " .$sitename. " " .$username. "!\n\nTo verify your email address, please click on the link below:\n\n".$base. "verify.php?a=" .$gen_key;
$mail->AddAddress($email);
$mail->Send();
$mail->ClearAddresses();
To maximize the odds of your email arriving, there are three things you need to check:
Make sure the computer sending the email has a Reverse PTR record
Configure DomainKeys Identified Mail (DKIM) in your DNS and code
Set up a SenderID record in your DNS
details at:
http://www.codinghorror.com/blog/2010/04/so-youd-like-to-send-some-email-through-code.html
There's not much you can do about it. Most of those mail providers have lists of common IP addresses, hostnames, and other data that often get flagged as spam and if your emails match the criteria they automatically get filtered. All you can really do is tell your visitors to add your email address to their allow list before registering so the email will go through to their inbox.
Honestly, don't worry about it. If they see your emails are regularly being marked as 'not spam' then they'll eventually add an exception for it. Just tell users to check their spam folder if they don't see the email like every other site does. Usually if they mark it as 'not spam' in that folder it will automatically add an exception for that address so any other emails you send them will end up in their inbox.
Do you have a reverse DNS entry for the server sending the confirmation e-mails?
If not, this might be a rDNS issue. Some sites are much more likely to mark a message as SPAM if the IP and name of the sending host don't match according to rDNS.
Otherwise, you might try sending confirmation e-mails to your own accounts on major e-mail sites like yahoo, hotmail and g-mail and then tweaking the wording until it gets past the spam filters.
Hm, there is SOMETHING you can do:
* Scrap the HTML. This looks like spam, especially with low text
* Write some more text, please.
Short HTML mails may rise up quite on the spam list.
I discovered that any variation of the word "confirm" in the title ends up in my spam bucket. I found other words that also do this: "purchase", "hurry", "order", "bargain", and "imminent".
This may not be true in all emails, but it happens in mine. It may be because those words appear in most of the emails I mark as span. It also may be that a local sysop made a filter and distributed it to all of us.
You can try using sendGrid apis which will helps, they charge but I think it is worthy. They support most popular languages : Nodejs, PHP, Java, ....

Categories