我正在尝试在PHP中为SMS消息传递程序创建API。除了一件事以外,一切都有效。它得到&carrier
和&number
,但PHP似乎无法将它们组合在一起。有什么建议?我试过调试它。
我的整个代码:
<br>
<br>
<b>Debugging info:</b>
<br>
<?php
$number = trim(strtolower($_GET['number']));
$from = trim(strtolower($_GET['from']));
$message = trim(strtolower($_GET['message']));
$subject = trim(strtolower($_GET['subject']));
$amount = trim(strtolower($_GET['amount']));
$number2 = $number. "@" .$carrier;
print_r($_GET);
require 'PHPMailerAutoload.php';
switch($_GET['carrier']){
case 'AT&T':
$carrier = "txt.att.net";
break;
case 'Sprint':
$carrier = "messaging.sprintpcs.com";
break;
case 'Verizon':
$carrier = "vtext.com";
break;
case 'T-Mobile':
$carrier = "tmomail.net";
break;
case 'Soufian':
$carrier = "gin.nl";
break;
}
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'swiftserver.ddns.net'; // Specify main and backup server
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'server@swiftserver.ddns.net'; // SMTP username
$mail->Password = 'xxxxxxx'; // SMTP password
$mail->Port = 25591; //Set the SMTP port number - 587 for authenticated TLS
$mail->setFrom('fbi@fbi.gov',$from); //Set who the message is to be sent fr
$mail->AddAddress($number2); // Name is optional
$mail->WordWrap = 50; // Set word wrap to 50 characters
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = ''.$subject;
$mail->Body = ''.$message;
if ($amount > 50){
print("You can only send 50 messages at a time. Change the message number to 50 and refresh the page.");
}
else if($amount < 50){
for($i=0; $i < $amount; $i++)
{
if(!$mail->send()) {
echo 'Message could not be sent: ';
echo '' . $mail->ErrorInfo;
exit;
}
}
echo 'Your message has been sent ' .$amount;
echo ' time(s).';
}
?>
<html>
<br>
<br>
<br>
<br>
我遇到了
的问题$number2 = $number. "@" .$carrier;
答案 0 :(得分:1)
我可能错了,但尝试在switch语句之后放置这行$number2 = $number. "@" .$carrier;
,因为看起来你只在交换机中声明了$carrier
。希望这有效。
答案 1 :(得分:0)
代表OP回答:
在切换功能中,我只是将AT&amp; T改为ATT。