-2

I have this script:

<?php
    $to1 = $_GET["number"];
    $to2 = $_GET["at"];
    $subject = $_GET["sub"];
    $message = $_GET["message"];
    $from = "admin@chipperyman573.com";
    $headers = "From:" . $from;
    $fin = $to1+"@"+$to2;
    mail($to,$subject,$message,$headers);
?>

I go to this url:

http://chipperyman573.com/send.php?to1=whatsittoya573&to2=gmail.com&subject=Test&message=Test2

however I get no email in my gmail inbox. admin@chipperyman573.com does exist.

jeroen
  • 88,615
  • 21
  • 107
  • 128
TheKawlr
  • 7
  • 3
  • What have you done to troubleshoot this, what is the return value of `mail()`? – jeroen Jun 16 '13 at 03:10
  • youre gonna have to post more than that....like perhaps the mail class? – Kylie Jun 16 '13 at 03:10
  • @jeroen How do I get a return value? I am new to PHP. – TheKawlr Jun 16 '13 at 03:10
  • @KyleK That's all I have. Like I said I'm new to PHP. – TheKawlr Jun 16 '13 at 03:11
  • you know it is almost a guarantee to get spam if you post your email in a post here? – markasoftware Jun 16 '13 at 03:13
  • 1
    Assign the value `$result = mail(...);` and do a `var_dump($result);` to check and process the result. But you really should display errors as that would have notified you of the undefined variables: http://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display – jeroen Jun 16 '13 at 03:16
  • As Kolink mentioned, you can't add two strings together with `+`, use `.` (period) instead. Also use `var_dump($_GET)` to check whether all the fields are set. – noahnu Jun 16 '13 at 03:17
  • @TheKawlr You should not change the original code in your question according to the answers you receive as that leads to answers that make no sense although they might be correct. – jeroen Jun 16 '13 at 03:19
  • use PhpMailer or Swift mailer those are better ... also make sure you are using SPF and DKIM – NullPoiиteя Jun 16 '13 at 03:21

4 Answers4

1

You're passing an invalid variable $to to mail

mail($to,$subject,$message,$headers);

should be...

mail($fin,$subject,$message,$headers);
kuujo
  • 6,395
  • 1
  • 22
  • 20
1

In the link, you say subject=Test, but you use it like $subject = $_GET["sub"];?

Try this: $subject = $_GET["subject"];

Solved over chat, transcript:

enter image description here

Dave Chen
  • 10,617
  • 8
  • 35
  • 67
0

You define $fin but never use it. You use $to but never declare it.

This might have something to do with it not working ;)

Niet the Dark Absol
  • 301,028
  • 70
  • 427
  • 540
0

Your code should be like this...

<?php
$to1 = $_GET["number"];
$to2 = $_GET["at"];
$subject = $_GET["sub"];
$message = $_GET["message"];
$from = "admin@chipperyman573.com";
$headers = "From:" . $from;
$fin = $to1."@".$to2;
mail($fin,$subject,$message,$headers);
?>
Kylie
  • 10,000
  • 8
  • 37
  • 69