send emai using php code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
issacthiyagarajan
Forum Newbie
Posts: 1
Joined: Thu Jun 24, 2010 12:36 am

send emai using php code

Post by issacthiyagarajan »

iam new to php. i want to send mail to gmail account from my application. a test mail. i google it and tried many things but the mail was not receiving. plz help me regarding this. send me code for this mail application
davex
Forum Contributor
Posts: 101
Joined: Sat Feb 27, 2010 4:10 pm
Location: Namibia

Re: send emai using php code

Post by davex »

Hi,

Well PHP's inbuild mail system is usually a good place to start (http://www.php.net/manual/en/function.mail.php).

It's worth bearing in mind that on some setups you can't send mail and even if it gets sent self-generated mail often looks like spam - have you checked your gmail spam folder?

Is it your own server with internet access or a shared environment? Might be worth looking at the logs, especially maillog and checking that whatever mail delivery agent such as sendmail is running.

Cheers,

Dave.
internet-solution
Forum Contributor
Posts: 220
Joined: Thu May 27, 2010 6:27 am
Location: UK

Re: send emai using php code

Post by internet-solution »

davex wrote:Well PHP's inbuild mail system is usually a good place to start (http://www.php.net/manual/en/function.mail.php).
OP wants to send e-mail via gmail account, not the local mail server.
issacthiyagarajan wrote:i google it and tried many things but the mail was not receiving. plz help me regarding this. send me code for this mail application
Its less likely that anybody will send you the whole application. If you have tried many things, why not post some code so that someone here can help you.

Some clues - you will need to use fsockopen to establish a SMTP connection to gmail server. Then you will have to use TLS challenge response protocol to authenticate your account to gmail.
davex
Forum Contributor
Posts: 101
Joined: Sat Feb 27, 2010 4:10 pm
Location: Namibia

Re: send emai using php code

Post by davex »

issacthiyagarajan wrote:iam new to php. i want to send mail to gmail account from my application. a test mail. i google it and tried many things but the mail was not receiving. plz help me regarding this. send me code for this mail application
Maybe I am mistaken but looks like he wants to send to not from.

If the only need is to send to gmail anyway then he could use any standard SMTP mailer and connect to one of the gmail MX servers but using localised mail delivery will enable transmission to any destination account for future use.

Though internet-solution is entirely correct if you want to send from your gmail account you'll need to use authenticated SMTP. I'm pretty sure a few of the off-the-peg PHP mail applications will support this.

HTH,

Dave.
internet-solution
Forum Contributor
Posts: 220
Joined: Thu May 27, 2010 6:27 am
Location: UK

Re: send emai using php code

Post by internet-solution »

Davex is right. I have misread the first post.
Thank you for correcting me.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: send emai using php code

Post by Jonah Bron »

davex wrote:...of the off-the-peg PHP mail applications...
Swiftmailer.
Post Reply