I've try send email using TLS and port number is 587 with server name is smtp.gmail.com but always got error "error '8004020e'". I set SSL to false because the port 587 Authentication is TLS. Any wrong in my code?
Set objMail = Server.CreateObject("CDO.Message")
Set objConfig = CreateObject("CDO.Configuration")
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = false
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xx#gmail.com"
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "xx"
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objConfig.Fields.Update
Set objMail.Configuration = objConfig
objMail.From = "xx#gmail.com"
objMail.To = "yy#yahoo.com"
objMail.Subject = "Test EMAIL"
objMail.TextBody = "Test EMAIL"
objMail.HTMLBody = "fffffffffff"
objMail.Send
Set objMail = Nothing
Use port 465 instead and use ssl (smtpusessl = True) for Gmail or Amazon SES SMTP.
And also have to make sure (log in to the Gmail account mailbox, check if there are messages, that tell you about previous unsuccessful attempts) that the mailbox usage for the "old applications" are enabled... (it's a new "feature", that can be enabled on Yahoo and Google mail servers since not too long ago... Even maybe some mobile email clients will not work if this is not set.)
Related
NOTE: edited from original after I discovered the outlook version was 32-bit not 64-bit.
I have a legacy 32-bit VB6 program that uses outlook 2010 32bit (full version, not express) to send email. Works perfect on many machines except one machine with windows 7 (64-bit I assume). Not sure if all windows 7 machines don't work or just this one.
If I use the automation technique or the MAPI technique (as I call them, see code below) outlook sends the email but the mail server kicks it back as undeliverable saying the recipient does not exist.
Now if the automation technique is used outlook displays no UI and the email is sent in the background.
However if the MAPI technique is used outlook opens it's compose email dialog which allows the user to edit the email prior to sending. What is interesting is that the recipient email looks fine but will fail as undeliverable if sent. However if the recipient is deleted and re-typed then the email will succeed. I believe a copy and re-paste works also.
This tells me there must be one or more hidden illegal characters in the recipient email address (nulls perhaps?). The code to do this shown below is very plain and I can't think of any obvious fix. txtTo is a vb6 string with an email address and this is the field that is causing all the problems.
The error message:
Your message did not reach some or all of the intended recipients.
Subject: a test from daryls cpu #2
Sent: 11/17/2017 8:01 PM
The following recipient(s) cannot be reached:
'someemail#gmail.com' on 11/17/2017 8:01 PM
None of your e-mail accounts could send to this recipient.
Automation Technique
Dim mOutlookApp As Object
Set mOutlookApp = GetObject("", "Outlook.application")
Dim olNs As Object
Set olNs = mOutlookApp.GetNamespace("MAPI")
olNs.Logon
Dim OutMail As Object
Set OutMail = mOutlookApp.CreateItem(0)
'Set the To and Subject lines. Send the message.
With OutMail
.To = txtTo
.CC = txtCC
.Subject = txtSubjext
.HTMLBody = txtBody & vbCrLf
Dim myAttachments As Object
Set myAttachments = .Attachments
vAttach = Split(mAttachments, ",")
For i = 0 To UBound(vAttach)
myAttachments.add vAttach(i)
Next i
Dim myFolder As Object
Set myFolder = olNs.GetDefaultFolder(5) 'olFolderSent
Set .SaveSentMessageFolder = myFolder
StatusBar1.Panels(1).Text = "Status: Sending"
.send
End With
MAPI Technique
'Open up a MAPI session:
With frmMain.MAPISession1
.DownLoadMail = False
.Username = ""
.LogonUI = True
.SignOn
End With
With frmMain.MAPIMessages1
.SessionID = frmMain.MAPISession1.SessionID
.Compose
.MsgIndex = -1
.RecipIndex = 0
.RecipAddress = txtTo
.RecipDisplayName = txtTo
.RecipType = mapToList
If txtCC <> "" Then
.RecipIndex = 1
.RecipDisplayName = txtCC
.RecipAddress = txtCC
.RecipType = mapCcList
End If
'spaces are important! need one space for each attachment
'NOTE .MsgNoteText = " " MUST be there see.. KB173853 in microsoft
.MsgSubject = txtSubjext
.MsgNoteText = Space$(UBound(vAttach) + 1) & vbCrLf
.MsgNoteText = txtBody & vbCrLf
For i = 0 To UBound(vAttach)
.AttachmentIndex = i
.AttachmentPosition = i
.AttachmentType = mapData
.AttachmentName = GetFileFromPath(vAttach(i))
.AttachmentPathName = vAttach(i)
Next i
StatusBar1.Panels(1).Text = "Status: Sending"
.send True
End With
More Info:
I'm making some progress. The error has to do with email type in outlook not being SMTP. If on the send-to email in the outlook compose dialog you right-click on the email address then select outlook properties and change the email type to SMTP it will work. The type displayed is the email address itself, valid values seem to be 'mailto' and 'smtp'. So if I can set the email type from vb6 it should fix the error.
The 'Answer'? https://kb.intermedia.net/article/2344
I can't believe there is no fix for this...
RESOLVED!
I realize this topic is most likely of no interest to anyone programming in the 20th century but here is the fix:
.RecipAddress = "SMTP:" & txtTo
It just came to me. :)
I'm trying to make a vbs code that e-mails some text but the network here is blocking port 25 is there a way of doing this through port 80 or some way to send a message through port 80 at least.
I got this error code when I tried: 80040213
Here is my code:
dim strSMTPFrom, strSMTPTo, strSMTPRelay, strTextBody, strSubject, oMessage
strSMTPFrom = "email#gmail.com"
strSMTPTo = "email#gmail.com"
strSMTPRelay = "smtp-relay.gmail.com"
strTextBody = "test"
strSubject = "test"
Set oMessage = CreateObject("CDO.Message")
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configurati on/sendusing") = 2
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTPRelay
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configurati on/smtpserverport") = 25
oMessage.Configuration.Fields.Update
oMessage.Subject = strSubject
oMessage.From = strSMTPFrom
oMessage.To = strSMTPTo
oMessage.TextBody = strTextBody
oMessage.Send
Nowadays most ISPs block outgoing connections to port 25 in an attempt to fight botnet spam. There are 2 customary ways of dealing with this:
Send the mail through the ISP's mail servers (if the ISP provides a mail gateway for its customers).
Send the mail to a mail submission server hosted by yourself or your mail provider via an (authenticated) connection to port 587 (submission) or port 465 (smtps, deprecated).
Technically you can send mail via port 80 if you set up a mail server that accepts mail on that port. Doing so isn't common (or recommended) practice, though.
I am a newbie to linux and need some help on using mutt for my office MS exchange server.
I have installed mutt 1.5.23 with configure options: --enable-imap --with-ssl and --enable-hcache.
I think, I am able to login to my exchange account, but can not go beyond (read or send mails). Mutt logs in and then says connection closed with message
--Mutt: (no mailbox) [Msgs:0] --- (date/date) ----------(all)
Is there a problem with my .muttrc or .msmtprc? I have no idea. I am pasting contents of both the files:
.muttrc:
source /usr/local/etc/Muttrc
set realname = "Ashish Goel"
set from = "ashish.goel#abc.com"
set envelope_from = yes
set imap_user = "ashish.goel#abc.com"
set folder = "imaps://owa.abc.com/owa/INBOX"
set imap_authenticators = "login"
set mbox = "imaps://owa.abc.com/owa/INBOX"
set spoolfile = "imaps://owa.abc.com/owa/INBOX"
set record = "imaps://owa.abc.com/owa/Sent Items"
set postponed = "imaps://owa.abc.com/owa/Drafts"
set copy=yes
set smtp_url = "smtps://ashish.goel#abc.com#owa.abc.com/owa"
mailboxes !
set header_cache = ~/.mutt/headers
set message_cachedir = ~/.mutt/cache/bodies
set certificate_file = /etc/ssl/certs
set imap_check_subscribed = yes
set imap_keepalive = 300
set imap_passive = no
set mail_check = 60
set timeout = 15
set sendmail = "/usr/bin/msmtp"
set ssl_verify_host = no
set ssl_verify_dates = no
.msmtprc:
account work
host owa.abc.com/owa
port 587
from ashish.goel#abc.com
user ashish.goel#abc.com
auth ntml
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile ~/.msmtp.log
ntlmdomain MYDOMAIN
protocol smtp
account default : work
I had this problem with an Exchange 2010 server both on this and later versions of mutt. In the end, I found the problem went away after I reset my subscribed folders in IMAP. I did this by using our web mail gateway which also uses IMAP. If you don't have such a facility, try the tips here to generate a list of subscribed folders, change it, and see if the updated list now works for you..
These are my functioning configuration files:
.muttrc:
set sendmail="/usr/bin/esmtp"
set envelope_from=yes
set realname="Kitone Elvis Peter"
set from="Kitone Elvis Peter <elviskitone#gmail.com>"
set use_from=yes
set edit_headers=yes
set smtp_url = "smtp://elviskitone#gmail.com#smtp.gmail.com:587/"
set smtp_pass =""
set imap_user = "elviskitone#gmail.com"
set imap_pass = ""
set mail_check = 30
set move = no
set imap_keepalive = 900
set header_cache = "~/.mutt/cache/headers"
set message_cachedir = "~/.mutt/cache/bodies"
set certificate_file = "~/.mutt/certificates"
set folder = "imaps://imap.gmail.com:993"
set spoolfile = "+INBOX"
I used esmtprc instead of msmtprc.
.esmtprc:
identity "elviskitone#gmail.com"
hostname "smtp.gmail.com:587"
username "elviskitone#gmail.com"
password ""
starttls required
You also need to enable IMAP on your email if you haven't already. Plus, you need to give access to insecure or third party applications on your email, in email settings.
I'm working on a project for sending SMS using SMPP protocol and KANNEL.
Everything is working well; the only problem is that I'm still unable to get the acknowledgment, so I can't know if the message was successfully received by the client or if I should send it again.
Please, does anyone have an idea on how I can solve that? Or if there is a tool with a UI that I can use instead of KANNEL?
Here is my config file:
group = core
dlr-storage = internal
admin-port = 13000
admin-password = password
status-password = password
admin-allow-ip = ''
smsbox-port = 13001
log-level = 0
log-file = "/usr/local/kannel/logs/kannel.log"
box-allow-ip = "127.0.0.1"
group = smsbox
smsbox-id = BOX1
bearerbox-host = 127.0.0.1
sendsms-port = 13013
log-file = "usr/local/kannel/logs/smsbox.log"
log-level = 0
access-log = "usr/local/kannel/logs/access.log"
group = sendsms-user
username = user
password = password
group = smsc
smsc = smpp
smsc-id = SMSC1
host = my_host_ip
port = my_host_port
smsc-username = user
smsc-password = password
address-range = ""
system-type = ""
transceiver-mode = true
When sending your message, make sure you have your registered_delivery flag set appropriately.
Add dlr-mask = 31 to "group = sendsms-user"
OR
Using the Kannel HTTP API, set your dlr-mask. For example:
http://localhost:13013/cgi-bin/sendsms?username=tester&password=foobar&to=+12345678910&text=Test&dlr-mask=31
From the Kannel User Guide: "dlr-mask: Optional. Request for delivery reports with the state of the sent message. The value is a bit mask composed of: 1: Delivered to phone, 2: Non-Delivered to Phone, 4: Queued on SMSC, 8: Delivered to SMSC, 16: Non-Delivered to SMSC. Must set dlr-url on sendsms-user group or use the dlr-url CGI variable."
Been having an issue trying to move our ASP page CDO over to gmail. It's about to drive me crazy. I've done some exhaustive searching and I think my code is right but I still get the dreaded: CDO.Message.1 error '80040213' The transport failed to connect to the server. on oMail.Send. Any thoughts would be much appreciated. I'm beginning to think it may be a server firewall issue.
Const cdoSendUsingPickup = 1
Const cdoSendUsingPort = 2
Const cdoAnonymous = 0
Const cdoBasic = 1
Const cdoNTLM = 2
Set oMail = CreateObject("CDO.Message")
oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "info#domain.com"
oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
oMail.From = "info#domain.com"
oMail.To = "someone#domain.com"
oMail.Bcc = ""
'oMail.To = ""
oMail.Subject = ""
oMail.HTMLBody = "<font size='2' face='Verdana, Arial, Helvetica, sans-serif'>"
oMail.HTMLBody = oMail.HTMLBody + "Name: <b>"& request.form("Name")&"</b><br>"
oMail.HTMLBody = oMail.HTMLBody + "Phone: <b>"& request.form("Phone")&"</b><br>"
oMail.HTMLBody = oMail.HTMLBody + "Email: <b>"& request.form("Email")&"</b><br>"
oMail.HTMLBody = oMail.HTMLBody + "Best Time to Call: <b>"& request.form("BestTime")&"</b><br>"
oMail.HTMLBody = oMail.HTMLBody + "Question/Comment: <b>"& request.form("Comment")&"</b><br>"
oMail.HTMLBody = oMail.HTMLBody + "</font>"
oMail.Configuration.Fields.Update
oMail.Send
Set oMail = Nothing
Set oMailConfig = Nothing
Any thoughts or suggestions would be much appreciated. I've tried all the Google smtp ports 25,465, and 567. What am I missing?
Straight from Google's own instructions;
Standard configuration instructions:
Incoming Mail (POP3) Server - requires SSL: pop.gmail.com
Use SSL: Yes
Port: 995
Outgoing Mail (SMTP) Server - requires TLS or SSL: smtp.gmail.com
Use Authentication: Yes
Port for TLS/STARTTLS: 587
Port for SSL: 465
Server timeouts Greater than 1 minute, we recommend 5
Full Name or Display Name: [your name]
Account Name or User Name: your full email address (including #gmail.com or #your_domain.com)
Email Address: your email address (username#gmail.com or username#your_domain.com)
Password: your Gmail password
I would also check your server has dns resolution to smtp.gmail.com and check your firewall which maybe blocking port 465, as a test try connecting without SSL to see if you can connect on 25 (see this article - Unable to send emails using gmail smtp server
Suggestion for google:
If you're having trouble sending mail but you've confirmed that encryption is active for SMTP in your mail client, try to configure your SMTP server on a different port (465 or 587).