24 May 2012 14:10
Re: problem sending email
Matijn Woudt <tijnema <at> gmail.com>
2012-05-24 12:10:30 GMT
2012-05-24 12:10:30 GMT
On Thu, May 24, 2012 at 2:00 PM, As'ad Djamalilleil <asad.kom <at> gmail.com> wrote:
> hi all,i'm having this problem in sending email using pear.
> it just wont send :(
> here's the code ..
>
> <?php
> require_once 'Mail.php';
>
> $from_name = "My Self";
> $to_name = "My Friend";
> $subject = "Sending Trial";
> $mailmsg = "GOD please make it work";
>
> $From = "From: ".$from_name." <mymail <at> gmail.com>";
> $To = "To: ".$to_name." <someone <at> yahoo.com>";
Don't prefix with From: and To: here.
> $recipients = "someone <at> yahoo.com";
>
> $headers["From"] = $From;
> $headers["To"] = $To;
> $headers["Subject"] = $subject;
> $headers["Content-Type"] = "text/plain; charset=iso-8859-1";
>
> $smtpinfo["host"] = "smtp.gmail.com";
> $smtpinfo["port"] = "465";
> $smtpinfo["auth"] = true;
> $smtpinfo["username"] = "mymail <at> gmail.com";
> $smtpinfo["password"] = "mypassword";
>
> $mail_object =& Mail::factory("smtp", $smtpinfo);
>
> $mail_object->send($recipients, $headers, $mailmsg);
>
> if (PEAR::isError($mail_object))
> echo $mail_object->getMessage();
> ?>
Also, Gmail SMTP supports only SSL connections. I don't know this PEAR
module, but I think you need to host set to something like
ssl://smtp.gmail.com, to enforce SSL connection.
- Matijn
--
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
RSS Feed