Reputation: 847
I'm using some code to send data to a database which also sends a confirmation email to the email address that was entered into the form field
For some strange reason, it only seems to send to my gmail account and nothing else like hotmail tiscali yahoo
Here's the code I'm using to send the email
// this send the receiver an email with the link to their ecard
mail("$receiveremail","Somebody loves you !", "<img src=\"http://www.somebodylovesyou.co.uk/images/email-header.jpg\" width=\"300\" height=\"57\">
</p>
<p>Hello $name,</p>
<p>Someone you know has sent you a secret valentine's message from http://www.somebodylovesyou.co.uk </p>
<p>You can view your message here : <a href='http://www.somebodylovesyou.co.uk/viewcard.php?rand=$eid'>http://www.somebodylovesyou.co.uk/viewcard.php?rand=$eid</a></P>
<P>Why not send a special someone a secret valentine's message at http://www.somebodylovesyou.co.uk</p>
<P>Happy Valentines", $headers);
// this send the receiver an email with the link to their ecard
mail("$youremail","View the message you've just sent", "<img src=\"http://www.somebodylovesyou.co.uk/images/email-header.jpg\" width=\"300\" height=\"57\">
</p>
<p>Hello,</p>
<p>Thanks for using Somebody Loves You </p>
<p>You can view the message you sent here : <a href='http://www.somebodylovesyou.co.uk/viewcard.php?rand=$eid'>http://www.somebodylovesyou.co.uk/viewcard.php?rand=$eid</a></P>
<P>Happy Valentine's", $headers);?>
I was advised to use these headers as well to help sending the emails but it doesnt seem to work
// these headers are for the purpose of sending the email replay to hotmail and yahoo addresses
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: SOMEBODY LOVES YOU <[email protected]>\r\n";
$headers .= "Reply-To: <[email protected]>\r\n";
$headers .= "X-Priority: 3\r\n";
$headers .= "X-MSMail-Priority: Normal\r\n";
$headers .= "X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409\r\n";
$headers .= "X-Mailer: Microsoft Outlook Express 6.00.2800.1409";
Upvotes: 1
Views: 1273
Reputation: 2282
Technically Gmail is exactly the same as any other e-mail service when it comes to the protocol, so I guess it's not a code-related problem.
What I'd check is your outgoing e-mail server and domain, especially two things:
These are e-mail forgery prevention techniques. Some e-mail services will automatically reject any mails without SPFs and DKIM.
Upvotes: 1
Reputation: 1010
It sounds like this is not an issue with your code. If it's arriving to one mail provider but not another then the other providers are blocking it or marking it as spam.
At this point what you want to look into ensuring MX records and other DNS records are correctly set to identify your server.
It's also possible that your domain / IP has been blacklisted. In that event each mail provider has steps you can take to get off their blacklist.
Upvotes: 0
Reputation: 1805
Try SwiftMailer It's very easy to utilize and it is very robust
$body = "<img src=\"http://www.somebodylovesyou.co.uk/images/email-header.jpg\" width=\"300\" height=\"57\"> </p> <p>Hello $name,</p> <p>Someone you know has sent you a secret valentine's message from http://www.somebodylovesyou.co.uk </p> <p>You can view your message here : <a href='http://www.somebodylovesyou.co.uk/viewcard.php?rand=$eid'>http://www.somebodylovesyou.co.uk/viewcard.php?rand=$eid</a></P> <P>Why not send a special someone a secret valentine's message at http://www.somebodylovesyou.co.uk</p> <P>Happy Valentines</p>";
$transport = Swift_MailTransport::newInstance();
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance($subject)
->setFrom(array("[email protected]" => "SOMEBODY LOVES YOU"))
->setTo(array($receiveremail))
->setBody($body, 'text/html');
$mailer->send($message);
Upvotes: 0