Solved

Using gmail smtp for cdosys

Posted on 2011-02-16
10
1,312 Views
Last Modified: 2012-05-11
I am using a gmail account for my email "me@mydomain.com".  The server that is hosting the domain thinks it is also hosting the email server.  As a result, when emails are sent from the site using the smtp server on the server(using cdosys) they never get "out" to the real world.  Can I use a gmail server to do this and, if so, how?  Otherwise, are there any other options?

Thanks~
0
Comment
Question by:Bob Schneider
  • 4
  • 3
  • 3
10 Comments
 
LVL 4

Accepted Solution

by:
ong-hh earned 250 total points
Comment Utility
0
 
LVL 11

Assisted Solution

by:yelbaglf
yelbaglf earned 250 total points
Comment Utility
Try something like this...

Dim objPasswd
objPasswd = "Password"

Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory. 
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network). 

Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM

Set objMessage = CreateObject("CDO.Message") 
objMessage.Subject = "Subject" 
objMessage.From = """From_Name"" <From@domain.org>" 
objMessage.To = "Email_Address@gmail.com; 5555555555@txt.att.net"
objMessage.TextBody = "Email Body." & vbCRLF & vbCRLF & "Continued."

'==This section provides the configuration information for the remote SMTP server.

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"

'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic

'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "Email_Address@gmail.com"

'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = objPasswd

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 

'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True

'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

objMessage.Configuration.Fields.Update

'==End remote SMTP server configuration section==

objMessage.Send

Open in new window

0
 

Author Comment

by:Bob Schneider
Comment Utility
Usiing the first solution I get this error:

The "SendUsing" configuration value is invalid
0
 

Author Comment

by:Bob Schneider
Comment Utility
Actually I fixed that but now i get an error when I try to send.  Here is my code:

Dim sSchema, iMsg, iConf, sFlds

sSchema = "http://schemas.microsoft.com/cdo/configuration/"

Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set sFlds = iConf.Fields

With sFlds
	.Item(sSchema & "sendusing") = 2
	.Item(sSchema & "smtpserver") = "smtp.gmail.com" 
	.Item(sSchema & "smtpserverport") = 465
	.Item(sSchema & "smtpauthenticate") = 1
	.Item(sSchema & "sendusername") = "username"
	.Item(sSchema & "sendpassword") =  "pword"
	.Item(sSchema & "smtpusessl") = 1
	.Update
End With

With iMsg
	.To = "bobs@h51software.net"
	.From = sEmail
	.Subject = "H51Software.net Email: " & sSubject
	.HTMLBody = sMsg
	Set .Configuration = iConf
	SendEmailGmail = .Send
End With

		
Set iMsg = Nothing
Set iConf = Nothing
Set sFlds = Nothing

Open in new window


Any ideas?
0
 
LVL 11

Assisted Solution

by:yelbaglf
yelbaglf earned 250 total points
Comment Utility
It seems the issue is with:

.From = sEmail

When I set it to something like the below, it works:

.From = "email@domain.com"

Is 'sEmail' dynamically filled via a form?
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 4

Assisted Solution

by:ong-hh
ong-hh earned 250 total points
Comment Utility
what is the error?
I did not get any error in my XP environment
0
 
LVL 4

Assisted Solution

by:ong-hh
ong-hh earned 250 total points
Comment Utility
With iMsg
      .To = "bobs@h51software.net"
      .From = <>
      .Subject = "H51Software.net Email: " & <>
      .HTMLBody = <>
      Set .Configuration = iConf
      SendEmailGmail = .Send
End With


You need to fill in the <> values
0
 

Author Comment

by:Bob Schneider
Comment Utility
Yes it is a variable that is populated from a form.  Is there any way around that?
0
 
LVL 11

Assisted Solution

by:yelbaglf
yelbaglf earned 250 total points
Comment Utility
The first thing I would do is double-check all the form and variable names, ensuring there are not typos or mismatches.
0
 

Author Comment

by:Bob Schneider
Comment Utility
I will do that but it was working in the old cdosys system.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now