通过短信网关发送的电子邮件未被接收。

8
我正在尝试使用C# Windows应用程序从Gmail帐户向卡纳塔克邦的airtel手机发送免费短信。消息已发送,我可以看到已发送项目,但未被移动电话接收。
这是我的代码:
SmtpClient smtp = new SmtpClient();
smtp.Credentials = new NetworkCredential("youraccount@gmail.com", "activedust");          
smtp.Port = 587;
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network; 
MailMessage message = new MailMessage();

message.To.Add("919845no@airtelkk.com");//replace  no with airtel mobile number in Karnataka

message.From = new MailAddress("youraccount@gmail.com", "App",System.Text.Encoding.UTF8);
message.Body = "type your body";
message.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
smtp.send(message);

我可以使用这段代码成功发送电子邮件,但短信无法工作。

尝试将电子邮件发送到其他地方,以检查它是否实际上作为电子邮件而不是短信接收。 - Henrik Gering
1
电子邮件到短信网关在可靠地传递消息方面声名狼藉。你很有可能被运营商屏蔽或标记为垃圾邮件。 - John Sheehan
使用smtp不需要任何帐户。 - user2284570
这个问题还有效吗?已经过去一年半了。 - Srikanth Venugopalan
1
@smileever143,请检查该号码是否已开启DND服务。开启DND服务的号码将无法接收来自特殊号码的短信,同时还有其他一些限制。请告知您是否正在尝试发送给DND号码。 - SpringLearner
检查该号码的DND服务。 - Avinash patil
2个回答

2

有一种方法是通过你的Gmail帐户发送文本消息。

using System.Net;
using System.Net.Mail;

public void SendTextMessage(string subject, string message, long telephoneNumer)
        {
            // login details for gmail acct.
            const string sender = "me@gmail.com";
            const string password = "mypassword4gmailacct";

            // find the carriers sms gateway for the recipent. txt.att.net is for AT&T customers.
            string carrierGateway = "txt.att.net";

            // this is the recipents number @ carrierGateway that gmail use to deliver message.
            string recipent = string.Concat(new object[]{
            telephoneNumer,
            '@',
            carrierGateway
            });

            // form the text message and send
            using (MailMessage textMessage = new MailMessage(sender, recipent, subject, message))
            {
                using (SmtpClient textMessageClient = new SmtpClient("smtp.gmail.com", 587))
                {
                    textMessageClient.UseDefaultCredentials = false;
                    textMessageClient.EnableSsl = true;
                    textMessageClient.Credentials = new NetworkCredential(sender, password);
                    textMessageClient.Send(textMessage);
                }
            }
        }

查看短信网关列表,请访问http://en.wikipedia.org/wiki/List_of_SMS_gateways

注意:当收件人回复消息时,该消息将发送到您的Gmail帐户...非常适合备份Smile | :) 并阅读如何在Windows应用程序中使用SMTP服务器向移动设备发送短信?


2

您需要在指定的手机号码上激活此服务。如果未激活,则将无法在手机上接收短信,需要支付49元或类似费用。

如果没有激活,您可以激活并再次尝试。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接