PHP mail function not sending email to Gmail account?
I am working on a WordPress plugin in which I send email using the PHP mail function, but there is a problem with the mail function. It sends emails to my non-Gmail account, but it's doesn't send emails to my Gmail account. I am using following code:
function send_mail()
global $wpdb;
$to = 'mymail@gmail.com';
$subject = 'Hello';
$name='my name';
$from="name@mydomain.com";
$message = "
<html>
<head>
<title>my title</title>
</head>
<body>
<div>
<tt> ".Hii How Are you."</tt>
</div>
</body>
</html>";
$header = "MIME-Version: 1.0rn";
$header .= "Content-type: text/html; charset=iso-8859-1rn";
$header .= "From: ".$name."<".$from.">rn";
mail($to, $subject, $message, $header);
Is there something wrong with my code, or is there some issue with the mail function? If any alternate method is available to send email, please give me the link.
php wordpress email plugins
|
show 2 more comments
I am working on a WordPress plugin in which I send email using the PHP mail function, but there is a problem with the mail function. It sends emails to my non-Gmail account, but it's doesn't send emails to my Gmail account. I am using following code:
function send_mail()
global $wpdb;
$to = 'mymail@gmail.com';
$subject = 'Hello';
$name='my name';
$from="name@mydomain.com";
$message = "
<html>
<head>
<title>my title</title>
</head>
<body>
<div>
<tt> ".Hii How Are you."</tt>
</div>
</body>
</html>";
$header = "MIME-Version: 1.0rn";
$header .= "Content-type: text/html; charset=iso-8859-1rn";
$header .= "From: ".$name."<".$from.">rn";
mail($to, $subject, $message, $header);
Is there something wrong with my code, or is there some issue with the mail function? If any alternate method is available to send email, please give me the link.
php wordpress email plugins
checkerror_logwhy the email is not been sent. there something to do with your server may be smtp is not configured..
– zzlalani
Nov 8 '13 at 6:16
you better usephpmailercode.google.com/a/apache-extras.org/p/phpmailer for php.
– zzlalani
Nov 8 '13 at 6:16
It may be becouse gmail does not accept email from non verified domain.
– Dinesh
Nov 8 '13 at 6:18
Your message's subject and body very likely triggered the SPAM filter, you miss "Check this out [random link here]" and you've made en plein .Try sending a more structured message and see if the problem is still there
– Damien Pirsy
Nov 8 '13 at 6:20
@zzlalani: is phpmailer works on IIS server?
– Jay
Nov 8 '13 at 6:27
|
show 2 more comments
I am working on a WordPress plugin in which I send email using the PHP mail function, but there is a problem with the mail function. It sends emails to my non-Gmail account, but it's doesn't send emails to my Gmail account. I am using following code:
function send_mail()
global $wpdb;
$to = 'mymail@gmail.com';
$subject = 'Hello';
$name='my name';
$from="name@mydomain.com";
$message = "
<html>
<head>
<title>my title</title>
</head>
<body>
<div>
<tt> ".Hii How Are you."</tt>
</div>
</body>
</html>";
$header = "MIME-Version: 1.0rn";
$header .= "Content-type: text/html; charset=iso-8859-1rn";
$header .= "From: ".$name."<".$from.">rn";
mail($to, $subject, $message, $header);
Is there something wrong with my code, or is there some issue with the mail function? If any alternate method is available to send email, please give me the link.
php wordpress email plugins
I am working on a WordPress plugin in which I send email using the PHP mail function, but there is a problem with the mail function. It sends emails to my non-Gmail account, but it's doesn't send emails to my Gmail account. I am using following code:
function send_mail()
global $wpdb;
$to = 'mymail@gmail.com';
$subject = 'Hello';
$name='my name';
$from="name@mydomain.com";
$message = "
<html>
<head>
<title>my title</title>
</head>
<body>
<div>
<tt> ".Hii How Are you."</tt>
</div>
</body>
</html>";
$header = "MIME-Version: 1.0rn";
$header .= "Content-type: text/html; charset=iso-8859-1rn";
$header .= "From: ".$name."<".$from.">rn";
mail($to, $subject, $message, $header);
Is there something wrong with my code, or is there some issue with the mail function? If any alternate method is available to send email, please give me the link.
php wordpress email plugins
php wordpress email plugins
edited Nov 8 '13 at 6:24
Seabody
5971719
5971719
asked Nov 8 '13 at 6:04
JayJay
2792926
2792926
checkerror_logwhy the email is not been sent. there something to do with your server may be smtp is not configured..
– zzlalani
Nov 8 '13 at 6:16
you better usephpmailercode.google.com/a/apache-extras.org/p/phpmailer for php.
– zzlalani
Nov 8 '13 at 6:16
It may be becouse gmail does not accept email from non verified domain.
– Dinesh
Nov 8 '13 at 6:18
Your message's subject and body very likely triggered the SPAM filter, you miss "Check this out [random link here]" and you've made en plein .Try sending a more structured message and see if the problem is still there
– Damien Pirsy
Nov 8 '13 at 6:20
@zzlalani: is phpmailer works on IIS server?
– Jay
Nov 8 '13 at 6:27
|
show 2 more comments
checkerror_logwhy the email is not been sent. there something to do with your server may be smtp is not configured..
– zzlalani
Nov 8 '13 at 6:16
you better usephpmailercode.google.com/a/apache-extras.org/p/phpmailer for php.
– zzlalani
Nov 8 '13 at 6:16
It may be becouse gmail does not accept email from non verified domain.
– Dinesh
Nov 8 '13 at 6:18
Your message's subject and body very likely triggered the SPAM filter, you miss "Check this out [random link here]" and you've made en plein .Try sending a more structured message and see if the problem is still there
– Damien Pirsy
Nov 8 '13 at 6:20
@zzlalani: is phpmailer works on IIS server?
– Jay
Nov 8 '13 at 6:27
check
error_log why the email is not been sent. there something to do with your server may be smtp is not configured..– zzlalani
Nov 8 '13 at 6:16
check
error_log why the email is not been sent. there something to do with your server may be smtp is not configured..– zzlalani
Nov 8 '13 at 6:16
you better use
phpmailer code.google.com/a/apache-extras.org/p/phpmailer for php.– zzlalani
Nov 8 '13 at 6:16
you better use
phpmailer code.google.com/a/apache-extras.org/p/phpmailer for php.– zzlalani
Nov 8 '13 at 6:16
It may be becouse gmail does not accept email from non verified domain.
– Dinesh
Nov 8 '13 at 6:18
It may be becouse gmail does not accept email from non verified domain.
– Dinesh
Nov 8 '13 at 6:18
Your message's subject and body very likely triggered the SPAM filter, you miss "Check this out [random link here]" and you've made en plein .Try sending a more structured message and see if the problem is still there
– Damien Pirsy
Nov 8 '13 at 6:20
Your message's subject and body very likely triggered the SPAM filter, you miss "Check this out [random link here]" and you've made en plein .Try sending a more structured message and see if the problem is still there
– Damien Pirsy
Nov 8 '13 at 6:20
@zzlalani: is phpmailer works on IIS server?
– Jay
Nov 8 '13 at 6:27
@zzlalani: is phpmailer works on IIS server?
– Jay
Nov 8 '13 at 6:27
|
show 2 more comments
3 Answers
3
active
oldest
votes
Check if adding fifth variable works for you... here is my code for sending emails.
if( mail( $recipient, $subject, $message, $headers, "-f noreply@mydomain.com"))
return "success";
its not working.
– Jay
Nov 8 '13 at 7:42
add a comment |
Check the spam folder, It might be there. Its a server issue, it hapened to me also many times. Gmail blocks mails or sends to spam from some servers due to some reasons. Ask your server provider to check why mails are not going to gmail inbox.
add a comment |
use the code sample as below, email address in <> and that last paramter worked for me.
$headers = 'From: <test@test.com>' . "rn" .
'Reply-To: <test@test.com>';
mail('<myEmail@gmail.com>', 'the subject', 'the message', $headers,
'-fwebmaster@example.com');
?>
It is the answer provided in PHP mail() function will not send to gmail but will send to my non-gmail account by ARH3, which i have tried and tested
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f19852615%2fphp-mail-function-not-sending-email-to-gmail-account%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Check if adding fifth variable works for you... here is my code for sending emails.
if( mail( $recipient, $subject, $message, $headers, "-f noreply@mydomain.com"))
return "success";
its not working.
– Jay
Nov 8 '13 at 7:42
add a comment |
Check if adding fifth variable works for you... here is my code for sending emails.
if( mail( $recipient, $subject, $message, $headers, "-f noreply@mydomain.com"))
return "success";
its not working.
– Jay
Nov 8 '13 at 7:42
add a comment |
Check if adding fifth variable works for you... here is my code for sending emails.
if( mail( $recipient, $subject, $message, $headers, "-f noreply@mydomain.com"))
return "success";
Check if adding fifth variable works for you... here is my code for sending emails.
if( mail( $recipient, $subject, $message, $headers, "-f noreply@mydomain.com"))
return "success";
answered Nov 8 '13 at 7:12
KhanKhan
84111129
84111129
its not working.
– Jay
Nov 8 '13 at 7:42
add a comment |
its not working.
– Jay
Nov 8 '13 at 7:42
its not working.
– Jay
Nov 8 '13 at 7:42
its not working.
– Jay
Nov 8 '13 at 7:42
add a comment |
Check the spam folder, It might be there. Its a server issue, it hapened to me also many times. Gmail blocks mails or sends to spam from some servers due to some reasons. Ask your server provider to check why mails are not going to gmail inbox.
add a comment |
Check the spam folder, It might be there. Its a server issue, it hapened to me also many times. Gmail blocks mails or sends to spam from some servers due to some reasons. Ask your server provider to check why mails are not going to gmail inbox.
add a comment |
Check the spam folder, It might be there. Its a server issue, it hapened to me also many times. Gmail blocks mails or sends to spam from some servers due to some reasons. Ask your server provider to check why mails are not going to gmail inbox.
Check the spam folder, It might be there. Its a server issue, it hapened to me also many times. Gmail blocks mails or sends to spam from some servers due to some reasons. Ask your server provider to check why mails are not going to gmail inbox.
answered Nov 8 '13 at 6:16
SajalSajal
77911126
77911126
add a comment |
add a comment |
use the code sample as below, email address in <> and that last paramter worked for me.
$headers = 'From: <test@test.com>' . "rn" .
'Reply-To: <test@test.com>';
mail('<myEmail@gmail.com>', 'the subject', 'the message', $headers,
'-fwebmaster@example.com');
?>
It is the answer provided in PHP mail() function will not send to gmail but will send to my non-gmail account by ARH3, which i have tried and tested
add a comment |
use the code sample as below, email address in <> and that last paramter worked for me.
$headers = 'From: <test@test.com>' . "rn" .
'Reply-To: <test@test.com>';
mail('<myEmail@gmail.com>', 'the subject', 'the message', $headers,
'-fwebmaster@example.com');
?>
It is the answer provided in PHP mail() function will not send to gmail but will send to my non-gmail account by ARH3, which i have tried and tested
add a comment |
use the code sample as below, email address in <> and that last paramter worked for me.
$headers = 'From: <test@test.com>' . "rn" .
'Reply-To: <test@test.com>';
mail('<myEmail@gmail.com>', 'the subject', 'the message', $headers,
'-fwebmaster@example.com');
?>
It is the answer provided in PHP mail() function will not send to gmail but will send to my non-gmail account by ARH3, which i have tried and tested
use the code sample as below, email address in <> and that last paramter worked for me.
$headers = 'From: <test@test.com>' . "rn" .
'Reply-To: <test@test.com>';
mail('<myEmail@gmail.com>', 'the subject', 'the message', $headers,
'-fwebmaster@example.com');
?>
It is the answer provided in PHP mail() function will not send to gmail but will send to my non-gmail account by ARH3, which i have tried and tested
edited May 23 '17 at 12:29
Community♦
11
11
answered Jun 18 '15 at 17:22
Bikram ShresthaBikram Shrestha
1,2701721
1,2701721
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f19852615%2fphp-mail-function-not-sending-email-to-gmail-account%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
check
error_logwhy the email is not been sent. there something to do with your server may be smtp is not configured..– zzlalani
Nov 8 '13 at 6:16
you better use
phpmailercode.google.com/a/apache-extras.org/p/phpmailer for php.– zzlalani
Nov 8 '13 at 6:16
It may be becouse gmail does not accept email from non verified domain.
– Dinesh
Nov 8 '13 at 6:18
Your message's subject and body very likely triggered the SPAM filter, you miss "Check this out [random link here]" and you've made en plein .Try sending a more structured message and see if the problem is still there
– Damien Pirsy
Nov 8 '13 at 6:20
@zzlalani: is phpmailer works on IIS server?
– Jay
Nov 8 '13 at 6:27