esafwan
esafwan

Reputation: 18029

Using curl to send mail from gmail

Is it possible to login to my gmail account and send mail using curl in php? I don't want to use pop3 or any other function.

$msg = "something";
$email = "[email protected]";
$pass= "something"

function send($msg, $email, $pass)
{
//something
}

I have never used curl, to be honest. Have just heard of it.

Upvotes: 0

Views: 5275

Answers (5)

Motomotes
Motomotes

Reputation: 4237

Libcurl is designed to support smtp email since version 7.20 (April 2010). It also support several authentication methods (SSL, TLS, CRAM-MD5)

Upvotes: 0

mtomy
mtomy

Reputation: 1595

You may do it with libcurl without many troubles. Here is an example http://curl.haxx.se/libcurl/c/smtp-tls.html of how to send email using TLS (all you need to send via gmail) in C. I believe libcurl PHP port provides the same ability.

Upvotes: 2

Ronn0
Ronn0

Reputation: 2269

I should use SMTP for it, there are some great mailer classes for SMTP (E.g. Zend_Mail). Zend components can be use stand alone and are very great.

Upvotes: 0

vlad b.
vlad b.

Reputation: 695

I believe it is possible but the codebase would be huge and the benefits very small compared with using imap or pop3 or other services.

Why do you want to do this?

p.s. gmail has a limit on the numbers of email you cand send per hour, as far as i know. So, if you're trying to use gmail to send mass emails i would advise against it.

Upvotes: 0

Pekka
Pekka

Reputation: 449813

It is theoretically possible, but extremely complex and subject to breaking whenever Google decide to change their HTML interface. Not a good idea.

Your best option is to use Google Mails's SMTP servers. Mailer packages like SwiftMailer make this easy to set up.

Here is an example for how to connect to GMail with SMTP.

Upvotes: 5

Related Questions