0
votes

I have a C# application that sends email notifications to users. I am trying to use the application to send text alerts as well (for reminders, mostly). Our provider is Verizon, so it is possible to send an Email as a text message, by emailing with the format: [email protected].

I've set my up application (which successfully sends emails to actual email addresses) with some phone numbers for testing, and the text messages are never recived. I can, however, successfully send emails as text messages through corporate mail accounts (we use Lotus Notes), and from my personal GMail account.

I'm not getting any errors...The text messages just never arrive. The code looks as such

public void SendMail(string address, string contents)
    {
        try
        {
            MailMessage mailMessage = new MailMessage();
            mailMessage.To.Add(address);                
            mailMessage.From = new MailAddress("email name removed");                
            mailMessage.Subject = "System Notification";
            mailMessage.Body = contents;
            SmtpClient smtpClient = new SmtpClient("client name removed");                

            Console.WriteLine("Mail sent to: " + address + "\n--> " 
            + contents + "\n");

            smtpClient.Send(mailMessage);
        }
        catch (Exception)
        { }
    }

Then, I call the method like so:

emailService.SendMail("[email protected]", message);
1
Ultimately, It seems that the issue is one of Network Authentication. Verizon seems to require some level of authentication, so to use my own SMTP server I would require access to a Verizon account login and password (which i do not currently have). That said, the answer below should work with said information, and I have accepted it. In my particular situation, I followed the instructions here: stackoverflow.com/questions/32260/… and created a gmail account to route emails through for the time being.aaron

1 Answers

1
votes

Try this configuration for the outgoing smtp :

  SmtpClient smtpClient = new SmtpClient("smtp.verizon.net", 465);

        MailMessage MyMailMessage = new MailMessage("[email protected]", "[email protected]",
            "write your subject Here ", "Hi,This is the test message ");
        MyMailMessage.IsBodyHtml = false;
        NetworkCredential mailAuthentication = new NetworkCredential("[email protected]", "password");

        mailClient.EnableSsl = true;
        mailClient.UseDefaultCredentials = false;
        mailClient.Credentials = mailAuthentication;
        mailClient.Send(MyMailMessage);