Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I send an email using PHP?

I am using PHP on a website and I want to add emailing functionality.

I have WampServer installed.

How do I send an email using PHP?

like image 946
user590849 Avatar asked Mar 17 '11 05:03

user590849


People also ask

Can PHP send email to Gmail?

Writing the PHP Code to Send Email using Gmail SMTPzip file, use this link. Unzip the master. zip in your application directory and run following command from your application directory. Composer is the recommended way to install PHPMailer.

Can I send email from localhost PHP?

Send Email from Localhost with PHPSet SMTP credentials (host, username, password, and port). Specify sender name and email ( $mail->setFrom ). Set recipient email address ( $mail->addAddress ). Set email subject ( $mail->Subject ).

How do I send PHP mail via SMTP?

php ini_set("SMTP", "aspmx.l.google.com"); ini_set("sendmail_from", "[email protected]"); $message = "The mail message was sent with the following mail setting:\r\nSMTP = aspmx.l.google.com\r\nsmtp_port = 25\r\nsendmail_from = [email protected]"; $headers = "From: [email protected]"; mail("[email protected]", " ...


1 Answers

It's possible using PHP's mail() function. Remember the mail function will not work on a local server.

<?php     $to      = '[email protected]';     $subject = 'the subject';     $message = 'hello';     $headers = 'From: [email protected]'       . "\r\n" .                  'Reply-To: [email protected]' . "\r\n" .                  'X-Mailer: PHP/' . phpversion();      mail($to, $subject, $message, $headers); ?> 

Reference:

  • mail
like image 133
Muthu Kumaran Avatar answered Oct 06 '22 07:10

Muthu Kumaran