PHP uses SMTP to send emails (PEAR)
PHPer mostly uses the mail function to send emails, but we can use other SMTP servers to send emails. we recommend that you use PEAR's mail package to send emails.
- $ Subject = "This mail is sent from SMTP .";
- $ Mail_body = "This is the body of the mail which is sent using SMTP .";
- $ From = "From: From Name ";
- $ To = "To: To Name ";
- $ Cycler = "toaddress@xpertdeveloper.com ";
-
- // Setting up the headers
- $ Headers ["From"] = $ from;
- $ Headers ["To"] = $;
- $ Headers ["Subject"] = $ subject;
- $ Headers ["Reply-To"] = "reply@address.com ";
- $ Headers ["Content-Type"] = "text/plain; charset = ISO-2022-JP ";
- $ Headers ["Return-path"] = "returnpath@address.com ";
-
- // Setting up the SMTP setting
- $ Smtp_info ["host"] = "smtp.server.com ";
- $ Smtp_info ["port"] = "25 ";
- $ Smtp_info ["auth"] = true;
- $ Smtp_info ["username"] = "smtp_user ";
- $ Smtp_info ["password"] = "smtp_password ";
-
- // Creating the PEAR mail object:
- $ Mail_obj = & Mail: factory ("smtp", $ smtp_info );
-
- // Sending the mail now
- $ Mail_sent = $ mail_obj-> send ($ receiver, $ headers, $ mail_body );
-
- // If any error the see for that here:
- If (PEAR: isError ($ mail_sent) {print ($ mail_sent-> getMessage ());}
|