Click here to Skip to main content
15,882,114 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Can we Send mail from Proxy Server using gmail.
if yes
then what should be the setting and code for this.
Plz Send me Information on [DELETED]@gmail.com"

[edit]Email address deleted - OriginalGriff[/edit]
Posted
Updated 13-Jul-12 21:05pm
v2
Comments
OriginalGriff 14-Jul-12 3:05am    
Never post your email address in any forum, unless you really like spam! If anyone replies to you, you will receive an email to let you know

Yes you can send mail through gmail to the client if the SMTP server is not installed.

C#
string emailid=emailtxt.Text;

 MailMessage mail = new MailMessage();
            mail.To.Add(emailid);
            
            mail.From = new MailAddress("xyz@gmail.com");
            mail.Subject = "Email using Gmail";

            string Body = "Hi all" ;
                       
            mail.Body = Body;
 
            mail.IsBodyHtml = true;
            SmtpClient smtp = new SmtpClient();
            smtp.Host = "smtp.gmail.com"; 
            smtp.Credentials = new System.Net.NetworkCredential
                 ("xyz@gmail.com", "yourpassword");
            
            smtp.EnableSsl = true;
            smtp.Send(mail);

yourpassword here is the gmail password.
 
Share this answer
 
v2
Send mail from Proxy Server using gmail
Yes, you can send. GMail has exposed it's SMTP server name(smtp.gmail.com) and PORT(587) for it.
Try:
VB
Imports System.Net.Mail
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
        Try
            Dim SmtpServer As New SmtpClient()
            Dim mail As New MailMessage()
            SmtpServer.Credentials = New Net.NetworkCredential("username@gmail.com", "password")
            SmtpServer.Port = 587
            SmtpServer.Host = "smtp.gmail.com"
            mail = New MailMessage()
            mail.From = New MailAddress("YOURusername@gmail.com")
            mail.To.Add("TOADDRESS")
            mail.Subject = "Test Mail"
            mail.Body = "This is for testing SMTP mail from GMAIL"
            SmtpServer.Send(mail)
            MsgBox("mail send")
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub
End Class


Still, In case needed, have a look at these:
Video: VB.NET - Sending an E-mail using Gmail - YouTube[^]
How to Send Mails from your GMAIL Account through VB.NET or C#. Windows Programming, with a Bit of Customization[^]
 
Share this answer
 
Comments
Rohit rgdon 14-Jul-12 5:22am    
Sir I have already written the Same Code but An Exception Comes "Failure Sending Mail"unable to connect to remote server.
Sandeep Mewara 14-Jul-12 6:36am    
Make sure that there is no firewall issue.
Sandeep Mewara 14-Jul-12 6:38am    
Also add this and see: SmtpServer.EnableSsl = True
No. The SMTPClient class doesn't support proxies.

There's really not even a specification for SMTP proxy support as far as I know. There are work arounds, but companies rarely ever let you get away with using them.

You would normally have a SMTP server INSIDE your proxy that can forward mail to outside mail servers.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900