Link to home
Start Free TrialLog in
Avatar of Bob Schneider
Bob SchneiderFlag for United States of America

asked on

CDO Issue with gmail smtp

I recently moved my cdo sys web email process to my gmail servers.  Now when someone sends me an email from the website it comes "From" my domain name, not the sender's email address.  This did not happen when I was using a different server.  How can I fix that?

Here is my code:
		If sHackMsg = vbNullString Then sEmail = CleanInput(Trim(Request.Form.Item("email")))
		If sHackMsg = vbNullString Then sSubject = CleanInput(Trim(Request.Form.Item("subject")))
		If sHackMsg = vbNullString Then sBody = CleanInput(Trim(Request.Form.Item("body")))
		
		If sHackMsg = vbNullString Then
			sMsg = "A Message from GSE Contact Us" & vbCrLf & vbCrLf
			sMsg = sMsg & "From: " & sYourName & vbCrLf
			sMsg = sMsg & "Email Address: " & sEmail & vbCrLf & vbCrLf
			sMsg = sMsg & "Message: " &vbCrLf 
			sMsg = sMsg & sBody

			Set cdoMessage = CreateObject("CDO.Message")
			With cdoMessage
				Set .Configuration = cdoConfig
				.To = "me@mydomain.com"
				.From = sEmail
				.Subject = sSubject
				.TextBody = sMsg
				.Send
			End With
			Set cdoMessage = Nothing
			
			bMsgSent = True

Open in new window

SOLUTION
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bob Schneider

ASKER

padas, I tried what you suggested but to no avail.  carrzkiss, are you serious???  SOB that is a HUGE inconvenience for my site users.

Can you think of any  workarounds??
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That REALLY sucks but I appreciate the insight.
yep...
I think I am confused.  

You have a web server, an old email server (may have been your web server) and now email through gmail.

You have a form on your web server that sends email to  you through your gmail.

You want the "from" to look like it is "from" the sender.  The "from" can be anything you want.   You may have to do MySendersEm@ail.com <myactual@email.com> at least that way you can see who sent it in your email.  But I would also put the info in your body.  

What will help you further is using authentication which you are not doing.  I use the below code as a base. Just note the port you will want to change for gmail can be the encrypted port I think is 465.

Using gmail for this kind of thing has limitations.  If you send a lot of mail like this, I would use a 3rd party smtp service which is what I do.  It does cost some dough but they take care of whitelisting and if you do get marked as spam, it is the ip for the smtp service,  not your actual email.   If you are just sending small amounts of one off emails to yourself, you are probably ok.    I have clients with paid gapps for business and I still use 3rd party smtp service.

But as far as just being able to see who sent you the mail from the form info, just put in the name portion and keep your email in the carrots.  name <myemail>




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 = "Example CDO Message"
objMessage.From = """mysenders name"" <me@my.com>"
objMessage.To = "me@mydomain"
objMessage.TextBody = "This is some sample message text.." & vbCRLF & "It was sent using SMTP authentication."

'==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") = "mail.your.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") = "youruserid"

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

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

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

'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
Let me be a little more clear:  I have a web "service" that cross-country coaches use to manage their teams.  It is www.etraxc.com/.  If a coach wants to send an email to their entire team they can do that through a form on the site.  I use cdo sys to do that, which requires an smtp server.  Before I was using the smtp on a third party (secureconnect.com) but I moved it to gmail.  

The upshot now is that when a coach sends an email to his team they can't simply reply to the email, they have to click on the coaches name and send a new email.  This is a huge inconvenience especially if they wanted to keep the email contents in the trail.

Does this help?
Hey padas.

See, Gmail, when sending webform mail, will not put the senders email address in the "From" line, instead, it will pick up on the main senders email address, in this case, if the email address that is hard coded in the mail script.

GMail does it this way, to stop PHISHING, I am not really sure how it works like that, but that is how they have it setup.
So, you cannot code it, no matter what you do.
Trust me, i tried and tried and tried, my darnedest, and I could not come up with anything, then I started searching, and found out that GMail has it like that by design.
That sounds right. I didn't get that the email was being sent out from a coach to somebody via his service.   Now that makes sense and I agree with what google is doing since they can not control what is happening.  You would need to either have your own mail server to do what you want or use a 3rd party smtp service.  I have been using sendgrid.    You can white label the outgoing accounts.
What is the cost for a third party such as sendgrid?
It depends on what you want. It starts out at $10 per month but the problem is that level does not include white listing for aol/comcast.  So the minimum is $80 per month for up to 100,000 emails.  So cheaper then the likes of constant contact.  You can have multiple sub accounts share one account although they would share the same IP. I think each additional IP is $20 or $30 per month.  Then just whitelabel each sub account http://sendgrid.com/docs/User_Guide/whitelabel_wizard.html.  I just will not send email from my server anymore.  Too much responsibility and work.  The auto email is more likely to be marked as spam especially if done from your server.  It's hard to find a shared web hosting service that will let you send out mail via the web server but you could get a cheap dedicated or cloud service just for sending out email and have 100% control.  It would end up costing you about the same per month except no limits.  But you would have to spend time getting and staying on ISP's white lists.  I stopped being cheap.  It doesn't pay.
If you have the bandwidth coming into your home or office.
For less than $1,000.00, you can purchase a server that you can then install
A mail server onto.

I have an older 2gb server right now, that I run for my bulk mailing, of which I have not utilized yet, to many other projects...

The only issue about having your own server, is that you have to get in contact with all the ISP's, to get yourself white-listed. Like AOL.

I prefer to run my own servers, and am hoping that by the Summer, I will have my own servers for all my domains.

Have a good one.
Time for sleep.

Carrzkiss
You folks are the best.  Thanks for the good advice!!