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
Related
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.
How to send email from wamp/xampp localhost?
I have written the following simple code to send message.
I have already edited php.ini,sendmail.ini configuration files but no use,I can't receive email.I want to send message to any gmail address.I can sent email to my domain mail when this piece of code is uploaded via filezilla to my domain, but when I am giving to address as any gmail id, the code is not working.
<?php
$to = "bytecookiestest#gmail.com";
$subject = "My subject";
$txt = "Hello world!";
$headers = "From: swetha851991#gmail.com";
$s=mail($to,$subject,$txt,$headers);
if($s)
echo "success";
else
echo "failure";
?>
It's most likely a problem with the from-header you're sending. You're using your own Gmail-address to send mails from, but that also means you have to use the Google SMTP server. The credentials of swetha851991#gmail.com are the credentials you have to use to authenticate with the SMTP server. It'll otherwise be marked as spam.
Another option is to set the from-address to an address from the domain you're sending it from. If you domain is example.com, you can set the from-address to anything#example.com.
I am working with PHP Mailer to send the mails. It working fine in my localhost. And when i tested it from my Linux server, i am receiving mails to all as fine except hotmail . Please find the below code im running.
<?php require_once('PHPMailer/class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->From = "no-repy#gmail.com"; //From Address -- CHANGE --
$mail->FromName = "myname"; //From Name -- CHANGE --
$mail->AddAddress('*****#hotmail.com'); //To Address -- CHANGE --
$mail->AddAddress('*****#gmail.com');
$mail->AddReplyTo("no-reply#gmail.com", "gmail"); //Reply-To Address -- CHANGE --
$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->IsHTML(false); // set email format to HTML
$mail->Subject = "AuthSMTP Test";
$mail->Body = "AuthSMTP Test Message!";
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
?>
After running this im getting the response as
Message has been sent
But receiving mail to my Gmail a/c, not to the Hotmail.
Please help regarding this one.
Thanks in advance.
I had the same problem; indeed mail arrived at other destinations except hotmail.
It turns out MS*** recently decided to block emails coming from godaddy mailers (secureserver.net). And these emails are not even sent to spam/deleted folders for hotmail recipients, they are just sent to the ether. Believe it or not.
After calls and mails to both parties, where of course you get no useful info or solution, I just decided to bypass their mailers and instead use a 3rd party service: sendgrid.com. Didn't use their smtp solution, as GD seems to blocks external smtp (at least in shared hosting); but the sendgrid-php works just fine.
is anybody know any solution for below problem
in my project, i am send email to client using smtp and php mailer and gmail script. so when i am send mail gmail send mail to particular client. for that i am passing gmail login and user name which is valid. all mail are sending properly. but sometime it may happen that some client not receive mail and at that time i am not able to get or trace any error. so i there any way, when i am sending mail to client , and when client get it and read it at that time i got any kind of confirmation.
Please if anybody have any idea , help me out.
<?php
/**
* Simple example script using PHPMailer with exceptions enabled
* #package phpmailer
* #version $Id$
*/
require ('../class.phpmailer.php');
try {
$mail = new PHPMailer(true); //New instance, with exceptions enabled
$body = "Please return read receipt to me.";
$body = preg_replace('/\\\\/','', $body); //Strip backslashes
$mail->IsSMTP(); // tell the class to use SMTP
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Port = 25; // set the SMTP server port
$mail->Host = "SMTP SERVER IP/DOMAIN"; // SMTP server
$mail->Username = "EMAIL USER ACCOUNT"; // SMTP server username
$mail->Password = "EMAIL USER PASSWORD"; // SMTP server password
$mail->IsSendmail(); // tell the class to use Sendmail
$mail->AddReplyTo("someone#something.com","SOMEONE");
$mail->From = "someone#something.com";
$mail->FromName = "SOMEONE";
$to = "other#something.com";
$mail->AddAddress($to);
$mail->Subject = "First PHPMailer Message[Test Read Receipt]";
$mail->ConfirmReadingTo = "someone#something.com"; //this is the command to request for read receipt. The read receipt email will send to the email address.
$mail->AltBody = "Please return read receipt to me."; // optional, comment out and test
$mail->WordWrap = 80; // set word wrap
$mail->MsgHTML($body);
$mail->IsHTML(true); // send as HTML
$mail->Send();
echo 'Message has been sent.';
} catch (phpmailerException $e) {
echo $e->errorMessage();
}
?>
Some modification need to be done in above script.
Configure SMTP mail server.
Set the correct FROM & FROM Name (someone#something.com, SOMEONE)
Set the correct TO address
from
also
Delivery reports and read receipts in PHP mail
You can always add reply to mail address which will take care if there is any error so you will get email back, and for if it's read, include a picture (blank picture of 1 pixel will do) and add code in that picture like and you can see how many hits that image did recieve or recieved any at all.
You can check that things in two different ways like, by using the header "Disposition-Notification-To" to your mail function, it will not going to work in all case because most people choose not to send read receipts. If you could, from your server, influence whether or not this happened, a spammer could easily identify active and inactive email addresses quite easily.
You can set header like
$email_header .= "Disposition-Notification-To: $from";
$email_header .= "X-Confirm-Reading-To: $from";
now the another method to check is by placing an image and you can add a script to onload of that image, that script will send notification to your system that xxx user have read the mail so, in that way you can track delivery status of the mail.
In fact, I can't think of any way to confirm it's been delivered without also checking it gets read, either by including a image that is requested from your server and logged as having been accessed, or a link that the user must visit to see the full content of the message.
Neither are guaranteed (not all email clients will display images or use HTML) and not all 'delivered' messages will be read.
Though for more info https://en.wikipedia.org/wiki/Email_tracking
I am using the following PHP CODE to send BULK MAIL .But Mails seems to Land in SPAM.I am using "phpmailer" class to send the mail.
require 'mailer/class.phpmailer.php';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->Username = "info#gmail.com";
$mail->Password = "Bexwa44Puciz"; // GMAIL password
$mail->AddReplyTo('info#gmail.com', 'Info');
$Appname = 'info.com';
$_subject="Newsletter From: ".$Appname;
$ema=",";
$to_bcc=explode(",",$ema);
$mail->AddCustomHeader($headers);
foreach($to_bcc as $tb){
$mail->AddBCC($tb, $dname);
}
$_body ="News content";//$hid;
$mail->FromName = "info.com";
$mail->From="inf#gmail.com";
$mail->Subject = $_subject;
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
$mail->MsgHTML($_body);
if($mail->Send()){
echo "Done";
}else {
echo "Failed";
}
I experienced same. My website sends requests for data confirmation to users a few times each day while I do my daily data maintenance. I sent a test message to my Gmail address and found that if you read your mail through Gmail webmail interface it will sometimes tell you Why the message was spammed. Very useful. It gave the reason "A lot of messages from hp19.hostpapa.com were spam". I am on a budget shared server and I assume a hundred other spammers have bought accounts on the same machine as mine and are using it for evil. My site is non-profit so buying a dedicated box to avoid spam is not an option. So...
My solution was to change my CMS to not use PHP mail() at all. Now my CMS simply displays the message and a mailto: link with Subject parameter set. Now my process is to hit CTRL+C, Click the link, CTRL+V, and hit send. Messages are sent from my computer's IP Address (not on any blacklist) using my mail client, Thunderbird.
This takes me just a couple of seconds longer than it did when my CMS used PHP mail() to send the message for me. However I have found I am receiving a lot more replies so I am happy that the vast majority of messages are not getting spam-binned.
I appreciate this manual solution is not appropriate for automated bulk messaging but for small non-profit sites on shared server who trigger each message with a click, I thought it was worth sharing.
There are a number of reasons you could be going into someones spam box. Your email server could be blacklisted due to either you, or another user on your server. You can check it at http://mxtoolbox.com/blacklists.aspx
Also check your SPF records in your DNS