我如何发送使用PHP在Windows Azure的电子邮件? [英] How can i send an Email using PHP at windows Azure?
问题描述
如何在Windows Azure中发送邮件使用PHP电子邮件?
我用简单的邮件功能:
$为='电子邮件ID。
$主题=测试对象;$标题='的MIME版本:1.0。 \\ r \\ n;
$标题='的Content-type:text / html的;字符集= ISO-8859-1。 \\ r \\ n;
$标题='到:'。$为''。 \\ r \\ n;
$标题=发件人:。$名字。 '<'。$电子邮件'>'。 。 \\ r \\ n;回声$消息='在这里电子邮件文本';
@mail($到,$主题,$消息,$头);
要使用PHP,你有几个选择发送电子邮件:
方法1:使用SMTP
您将需要修改您的的php.ini 配置文件( HTTP:/ /php.net/manual/en/ref.mail.php ),并设置SMTP值的外部 SMTP,你可以使用服务器。 SMTP服务器不是此刻在Windows Azure功能的一部分。
[邮件功能]
SMTP = mail.mycompany.com
选项2:使用sendmail
您将需要修改您的的php.ini 配置文件( HTTP:/ /php.net/manual/en/ref.mail.php )和sendmail_path值设置为sendmail的可执行文件。
[邮件功能]
sendmail_path =C:\\ WAMP \\ sendmail的\\ sendmail.exe -t
由于sendmail的不存在于Windows中,你需要使用假sendmail的窗户: http://glob.com.au/sendmail/
方法3:使用邮件/ SMTP服务
您可以使用像SendGrid服务来发送您的电子邮件(他们有Azure的用户报价: http://sendgrid.com/azure html的)。他们会照顾发送电子邮件的,你只需要调用REST API:
$ sendgrid =新SendGrid(用户名,密码);
$邮件=新SendGridMail();
$ MAIL-GT&; AddTo就('foo@bar.com') - GT;
setFrom('me@bar.com') - >
SETSUBJECT('主题放在这里') - GT;
的setText('!你好世界) - GT;
setHtml('<强>您好!世界< / STRONG>');
$ sendgrid->&SMTP的GT;发($邮件);
How can i send an Email using PHP at windows Azure?
i am using simple mail function:
$to .= 'email-Id';
$subject = " Test Subject";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To: '.$to.'' . "\r\n";
$headers .= 'From: '.$name. '<'.$email.'>' . "\r\n";
echo $message='email text here';
@mail($to, $subject, $message, $headers);
To send emails using PHP you have a few options:
Option 1: Use SMTP
You'll need to modify your php.ini configuration file (http://php.net/manual/en/ref.mail.php) and set the SMTP value to an external SMTP server you can use. SMTP servers are not part of the Windows Azure features at the moment.
[mail function]
SMTP = mail.mycompany.com
Option 2: Use sendmail
You'll need to modify your php.ini configuration file (http://php.net/manual/en/ref.mail.php) and set the sendmail_path value to the sendmail executable.
[mail function]
sendmail_path = "C:\wamp\sendmail\sendmail.exe -t"
Since sendmail doesn't exist in Windows, you'll need to use the fake sendmail for windows: http://glob.com.au/sendmail/
Option 3: Use a mail/smtp service
You could use a service like SendGrid to send your emails (they have an offer for Azure users: http://sendgrid.com/azure.html). They'll take care of sending out the email, you'll just need to call the REST api:
$sendgrid = new SendGrid('username', 'password');
$mail = new SendGridMail();
$mail->addTo('foo@bar.com')->
setFrom('me@bar.com')->
setSubject('Subject goes here')->
setText('Hello World!')->
setHtml('<strong>Hello World!</strong>');
$sendgrid->smtp->send($mail);
这篇关于我如何发送使用PHP在Windows Azure的电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!