Email Frowarder not working

Yes, try and see that…if it works for you.

Thanks for the feedback! From what I know, the sendmail is limited because we don’t want mass mail problems. Good luck with your studies!

1 Like

I’ve sent another two test emails this morning, one of them received instantly because the domain is mail.com (a big mailing company), just to find out that the email from yesterday has been received (after quite some time…) and has been thrown in the SPAM inbox, just like the email I’ve sent today.

In your e-mail form, alongside the normal email parameters, you have another one at the end called “Submit”. You should unlink it, as I don’t think it must appear in the headers. It might be the reason why your email is marked as SPAM.

unlink($_GET["Submit"]);

$to = explode(";", $_GET["to"]);
$subject = $_GET["subject"];
$text = $_GET["text"];
$headers = $_GET["headers"];

for($i = 0; $i < count($to); $i++){
	if( mail($to[$i], $subject, $text, $headers) ){
        // log "successful"
	} else {
        // log "failed"
	}
}

@ichhabsdraufn is your issue solved?

I just changed the “Forward to” email to a gmail account I have.

It is still not working, when I use the PHP Mailer. From Yahoo to info@andihamolli.tk to my gmail account wasn’t working as well.

I also checked the spam folder. But since it is just text it won’t land on spam

I just checked
I recieved the email from Yahoo => info@andihamolli.tk on my Gmail. (with delay)
With Script it didn’t work.

I have another file, where I get the form data:

    if(isset($_GET["submit"])){
		$header = "From:" . $_GET["from"];
		$to = $_GET["to"];
		$subject = $_GET["subject"];
		$text = $_GET["text"];
		if($header == "" || $to == "" || $text == ""){
            // one of the fields is empty
		} else {
			$url = domain() . "/mail/sendmail.php?headers=" . urlencode($header) . "&to=" . urlencode($to) . "&text=" . urlencode($text) . "&subject=" . urlencode($subject);
			$status = json_decode(file_get_contents($url), true);
		}
	}

Try this instead:

if(isset($_GET["submit"])){
	$header = "From:" . $_GET["from"];
	$to = "To:" . $_GET["to"];
	$subject = "Subject: " . $_GET["subject"];
	$text = $_GET["text"];
	if($header == "" || $to == "" || $text == ""){
        // one of the fields is empty
	} else {
		$url = domain() . "/mail/sendmail.php?headers=" . urlencode($header) . "&to=" . urlencode($to) . "&text=" . urlencode($text) . "&subject=" . urlencode($subject);
		$status = json_decode(file_get_contents($url), true);
	}
}
1 Like

I will but perhaps later cuz I have two exams for tomorrow. I don’t have much time.

Don’t worry.

Take your time :wink:

1 Like

I did not find any reference about this change on the web
http://php.net/manual/en/function.mail.php

But just to recap. I have two files:

sendmail.php

$to = explode(";", $_GET["to"]);
$subject = $_GET["subject"];
$text = $_GET["text"];
$headers = $_GET["headers"];

for($i = 0; $i < count($to); $i++){
	if( mail($to[$i], $subject, $text, $headers) ){
        // log "successful"
	} else {
        // log "failed"
	}
}

and htmlfile.php

    if(isset($_GET["submit"])){
		$header = "From:" . $_GET["from"];
		$to = $_GET["to"];
		$subject = $_GET["subject"];
		$text = $_GET["text"];
		if($header == "" || $to == "" || $text == ""){
            // one of the fields is empty
		} else {
			$url = domain() . "/mail/sendmail.php?headers=" . urlencode($header) . "&to=" . urlencode($to) . "&text=" . urlencode($text) . "&subject=" . urlencode($subject);
			$status = json_decode(file_get_contents($url), true);
		}
	}

From the second file I call the first one via file_get_centents() sending to it the necessary arguments for the mail() function.
However I did not find any reference about the change you advised me to do. I visited http://php.net/manual/en/function.mail.php

I think the issue is fixed, because I managed to send a mail which received instantly. :slight_smile:

From:    support@andihamolli.tk
To:      my@email.address
Subject: Support
Text:    This is a support test email.

My advice: try not to send e-mails with suspicious headers. They’ll have bigger chances to be be marked as spam.


PS: forget about the mail() reference. Your code is definitely fine :wink:

So should I replace my htmlfile.php with this code or will it work both ways?

No, I think it would be better if you would keep your original version (as long as it’s now working…). :wink:

1 Like