Jump to content

Using curl to send email through smtp


dpacmittal

Recommended Posts

I used an open-source library to send emails to my users on my site. It connected to gmail smtp and sent the mail using it. The script used fsockopen to connect to smtp but recently my shared host disabled it.

 

I want to know if it is possible to send email through gmail's smtp using Curl? If yes, how?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/194594-using-curl-to-send-email-through-smtp/
Share on other sites

Why not get yourself a decent host instead of hacking around the obvious limitations of shared / crappy hosting?

Well, thats always an option but I want to know if its possible using Curl. So far, google has not given good results. I am starting to suspect that curl cannot be used for the purpose. I want to confirm this.

FWIW, gmail offers support for IMAP.  This is how phones connect, as well as imap compatible clients like thunderbird or outlook.  Rather than trying to use curl, which will not work with gmail, because gmail is a giant javascript application, IMAP would be something you could actually accomplish.  You would need of course support for secure imap, and given the limitations of the hosting company, who knows what they might support or not.  Did you by any change attempt to engage them in regards to your outbound email issues?  Did you ask them how you could perform legitimate and legal outbound emailing via your php based code?  ISP's are understandably concerned about email blacklists, so there may be a particular set of hoops or configurations you need to jump through.

FWIW, gmail offers support for IMAP.  This is how phones connect, as well as imap compatible clients like thunderbird or outlook.  Rather than trying to use curl, which will not work with gmail, because gmail is a giant javascript application, IMAP would be something you could actually accomplish.  You would need of course support for secure imap, and given the limitations of the hosting company, who knows what they might support or not.  Did you by any change attempt to engage them in regards to your outbound email issues?  Did you ask them how you could perform legitimate and legal outbound emailing via your php based code?  ISP's are understandably concerned about email blacklists, so there may be a particular set of hoops or configurations you need to jump through.

ofcourse, I was not talking about curl connecting to port 80 and following human steps. I was talking about curl connecting to smtp port and sending the mail using smtp rules.

Most people use curl to scrape web information, since it was primarily designed for http.  Previously the answer would have been, absolutely not with curl.  The latest version of curl now supports smtp, but that support might not be available in the php api.  You certainly don't need curl to do smtp with php, as there are various packages out there beginning with the ones in PEAR that let you do mail queueing and smtp.  For example, phpclasses purports to have a couple of classes that will allow for this. 

 

http://www.phpclasses.org/blog/package/9/post/1-Sending-email-using-SMTP-servers-of-Gmail-Hotmail-or-Yahoo-with-PHP.html

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.