• GoDaddy Community
  • VPS & Dedicated Servers
  • VPS & Dedicated Servers

    cancel
    Showing results for 
    Show  only  | Search instead for 
    Did you mean: 
    Go to solution

    Handling POST method calls in Node.JS

    I have shared hosting and a VSP. I have Office 365 email, as well as Godaddy standard email. I have created an app in Node.JS, using Express and Nodemailer modules, to handle Post method calls from my contact form. The code, which looks like the below and gets the username and password from a non-public configuration file, works when running my website from my home server but not when run from either the GoDaddy VSP or shared hosting platforms.

     

    I understand that GoDaddy tightly controls how POST methods are handled through Office 365. But there still has to be a way to send email through Office 365 using code (other than PHP). If not, how should the transporter object keys be set up to send secure email using a standard webmail account through GoDaddy?

     

     
    app.post('/send', (req, res) => {
    	req.fields
    	req.files
    
    	if (!req.fields) {
    		res.sendFile(__dirname + '/contact-fail.html')
    	} else {
    		console.log(req.fields)
    		req.fields
    		let data = {
    			senderName: req.fields.name,
    			senderEmail: req.fields.email,
    			senderAddress: req.fields.address,
    			senderCity: req.fields.city,
    			senderState: req.fields.state,
    			senderZip: req.fields.zipcode,
    			senderTel: req.fields.telephone,
    			senderSubject: req.fields.subject,
    			senderComments: req.fields.comments
    		}
    				
    		let TextBody = {
    		senderMessageBody: data.senderComments
    		}
    			
    			
    		let transporter = nodemailer.createTransport({
    			host: 'smtp-mail.outlook.com',
    			port: 587,
    			secureConnection: false,
    			auth: {
    				user: 'cred.ANYUSERNAME',
    				pass: 'cred.ANYPASSWORD'
    			},
    			tls: {
    				ciphers: 'SSLv3'
    			}
    		})
    	
    		let mailOptions = {
    			from: 'admin@tottm.org', // sender address
    			to: 'admin@tottm.org', 
    			replyTo: data.senderEmail,
    			bcc: "[Email addresses]", //array of BCC receivers
    			subject: `Form Submission: ${data.senderSubject}`, 
    			text: TextBody.senderMessageBody
    		}
    		
    		transporter.sendMail(mailOptions, (error, info) => {
    			if (error) {
    				console.log(`An error has occurred. \n\n${error}`)
    				res.sendFile(__dirname + '/contact-fail.html')
    			} else {
    				console.log(`Message sent. \n\n${info}`)
    				res.sendFile(__dirname + '/contact-success.html')
    			}
    		})
    	}
    })
    
    
     
    1 ACCEPTED SOLUTION
    Super User II

    Hey there @milkandgin,

     

    GoDaddy is just an authorized retailer of the O365 packages. They don't actually handle anything on the backend as it is all on Microsoft servers. GoDaddy can help with setup and connecting your email to your domain, but this sort of issue is likely due to a Microsoft policy of some sort.

     

    You can always call support and ask to speak with the Productivity department for more info.



    I am a GoDaddy End User - Just Like You
    * Please note that I DO NOT answer private messages. Please ask your question in the proper forum so the answer can assist EVERYONE in the community and not just you. If you contact me via PM for help, I will give you a price quote for my personal services. Thanks! *

    Once your issue is resolved,
    please be sure to come back and click accept for the solution

    Get Better Support on the Community Boards!
    Etiquette When Asking for Help from the Community


    View solution in original post

    1 REPLY 1
    Super User II

    Hey there @milkandgin,

     

    GoDaddy is just an authorized retailer of the O365 packages. They don't actually handle anything on the backend as it is all on Microsoft servers. GoDaddy can help with setup and connecting your email to your domain, but this sort of issue is likely due to a Microsoft policy of some sort.

     

    You can always call support and ask to speak with the Productivity department for more info.



    I am a GoDaddy End User - Just Like You
    * Please note that I DO NOT answer private messages. Please ask your question in the proper forum so the answer can assist EVERYONE in the community and not just you. If you contact me via PM for help, I will give you a price quote for my personal services. Thanks! *

    Once your issue is resolved,
    please be sure to come back and click accept for the solution

    Get Better Support on the Community Boards!
    Etiquette When Asking for Help from the Community


    View solution in original post